@prt-ts/fluent-react-table-v2 9.47.1-build-2.0 → 9.47.1-build-4.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 +41 -18
- package/index.esm.d.ts +1 -0
- package/index.esm.js +41 -19
- 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/components/loading/Loading.d.ts +5 -4
- 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
|
},
|
|
@@ -1615,7 +1614,7 @@ const HideColumnIcon = bundleIcon$1(EyeTrackingOffFilled, EyeTrackingOffRegular)
|
|
|
1615
1614
|
const GroupExpandIcon = bundleIcon$1(TextExpandFilled, TextExpandRegular);
|
|
1616
1615
|
const GroupCollapseIcon = bundleIcon$1(TextCollapseFilled, TextCollapseRegular);
|
|
1617
1616
|
function HeaderCell({ header, table, tabAttributes }) {
|
|
1618
|
-
var _a
|
|
1617
|
+
var _a;
|
|
1619
1618
|
const { column, id } = header;
|
|
1620
1619
|
const { isDragging, attributes, listeners, setNodeRef, transform, transition, } = sortable.useSortable({
|
|
1621
1620
|
id: id
|
|
@@ -1625,7 +1624,11 @@ function HeaderCell({ header, table, tabAttributes }) {
|
|
|
1625
1624
|
transition
|
|
1626
1625
|
};
|
|
1627
1626
|
const styles = useTableHeaderStyles();
|
|
1628
|
-
const isLeafHeaders = ((
|
|
1627
|
+
const isLeafHeaders = React.useMemo(() => {
|
|
1628
|
+
const leafCols = table.getAllLeafColumns();
|
|
1629
|
+
console.log("isLeafHeader");
|
|
1630
|
+
return !!(leafCols === null || leafCols === void 0 ? void 0 : leafCols.find(col => col.id === header.column.id));
|
|
1631
|
+
}, [table, header.column.id]);
|
|
1629
1632
|
const headerCellCombinedStyles = getHeaderCellPinningStyles(column, isDragging, dndStyle);
|
|
1630
1633
|
if (header.isPlaceholder) {
|
|
1631
1634
|
return (jsxRuntime.jsx("th", Object.assign({ colSpan: header.colSpan, className: styles.tHeadCell, style: headerCellCombinedStyles, ref: setNodeRef }, attributes, listeners, { children: jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanResize(), children: jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: reactComponents.mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }) })));
|
|
@@ -1646,10 +1649,10 @@ function HeaderCell({ header, table, tabAttributes }) {
|
|
|
1646
1649
|
if (!header.column.getCanGroup())
|
|
1647
1650
|
return;
|
|
1648
1651
|
header.column.getToggleGroupingHandler()();
|
|
1649
|
-
}, appearance: "transparent", className: styles.tHeadContentBtn, icon: (
|
|
1652
|
+
}, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_a = {
|
|
1650
1653
|
asc: (jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(SortAscIcon, {}) })),
|
|
1651
1654
|
desc: (jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(SortDescIcon, {}) })),
|
|
1652
|
-
}[header.column.getIsSorted()]) !== null &&
|
|
1655
|
+
}[header.column.getIsSorted()]) !== null && _a !== void 0 ? _a : undefined, iconPosition: "after", children: [jsxRuntime.jsx("strong", { children: columnName }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsGrouped(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(GroupListRegular, {}) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsFiltered(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(FilterFilled, {}) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsPinned(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(PinRegular, {}) }) })] }) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: !!isLeafHeaders, children: jsxRuntime.jsx(HeaderMenu, { header: header, table: table }) })] }) })), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanResize(), children: jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: reactComponents.mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: !isLeafHeaders, children: jsxRuntime.jsx("div", { className: styles.tHeadNonLeafCellFakeBorder }) })] })));
|
|
1653
1656
|
}
|
|
1654
1657
|
function HeaderMenu(props) {
|
|
1655
1658
|
const { header, table } = props;
|
|
@@ -1718,27 +1721,29 @@ function HeaderRow(props) {
|
|
|
1718
1721
|
|
|
1719
1722
|
function TableHeader(props) {
|
|
1720
1723
|
const styles = useTableHeaderStyles();
|
|
1721
|
-
const { table, headerGroups
|
|
1724
|
+
const { table, headerGroups } = props;
|
|
1722
1725
|
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,
|
|
1726
|
+
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
1727
|
}
|
|
1725
1728
|
|
|
1726
1729
|
const useLoadingStyles = reactComponents.makeStyles({
|
|
1727
1730
|
invertedWrapper: {
|
|
1728
1731
|
backgroundColor: reactComponents.tokens.colorNeutralBackground1,
|
|
1729
1732
|
},
|
|
1730
|
-
row: Object.assign(
|
|
1733
|
+
row: Object.assign({ width: "100%", alignItems: "center", justifyContent: "space-between", display: "flex", position: "relative", paddingBottom: "10px", paddingTop: "10px" }, reactComponents.shorthands.gap("20px")),
|
|
1731
1734
|
});
|
|
1732
1735
|
|
|
1733
1736
|
const Loading = (props) => {
|
|
1734
|
-
|
|
1737
|
+
var _a;
|
|
1738
|
+
const { numberOfItems = 16, visibleColumns, table } = props;
|
|
1739
|
+
const selectionMode = ((_a = table.options.meta) === null || _a === void 0 ? void 0 : _a.rowSelectionMode) || "none";
|
|
1735
1740
|
const styles = useLoadingStyles();
|
|
1736
|
-
return (jsxRuntime.jsx("div", {
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1741
|
+
return (jsxRuntime.jsx("div", { style: { width: "100%" }, children: jsxRuntime.jsx(reactControlFlow.For, { each: [...Array(numberOfItems)], children: (rowIndex, index) => {
|
|
1742
|
+
return (jsxRuntime.jsxs(reactComponents.Skeleton, { className: styles.row, style: { width: "100%" }, children: [jsxRuntime.jsx(reactControlFlow.Show, { when: ["single", "multiple"].includes(selectionMode), children: jsxRuntime.jsx(reactComponents.SkeletonItem, { shape: "circle", size: 24, style: { width: "40px" } }, `${index}_select_row`) }), jsxRuntime.jsx(reactControlFlow.For, { each: visibleColumns || [], children: (column, i) => (jsxRuntime.jsx(reactComponents.SkeletonItem, { style: {
|
|
1743
|
+
minWidth: column.getSize(),
|
|
1744
|
+
width: "100%"
|
|
1745
|
+
} }, i)) })] }, `${rowIndex}_${index}`));
|
|
1746
|
+
} }) }));
|
|
1742
1747
|
};
|
|
1743
1748
|
|
|
1744
1749
|
const useNoItemGridStyles = reactComponents.makeStyles({
|
|
@@ -1944,7 +1949,7 @@ const TableContainer = (props) => {
|
|
|
1944
1949
|
const isLoading = props.isLoading && itemLength === 0;
|
|
1945
1950
|
const noItems = !isLoading && ((_a = props.data) === null || _a === void 0 ? void 0 : _a.length) === 0;
|
|
1946
1951
|
const noSearchResult = !isLoading && ((_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.length) > 0 && itemLength === 0;
|
|
1947
|
-
return (jsxRuntime.jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, style: { height: tableHeight }, children: [jsxRuntime.jsxs("table", { className: styles.table, "aria-label": "Data Grid", style: { width: table.getTotalSize(), minWidth: "100%" }, children: [jsxRuntime.jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsxRuntime.jsx(TableBody, { table: table, tableContainerRef: tableContainerRef })] }), jsxRuntime.jsxs(reactControlFlow.Switch, { when: true, children: [jsxRuntime.jsx(reactControlFlow.Case, { value: isLoading, children: jsxRuntime.jsx(Loading, {}) }), jsxRuntime.jsx(reactControlFlow.Case, { value: noItems, children: jsxRuntime.jsx(NoItemGrid, { message: props.noItemPage }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: noSearchResult, children: jsxRuntime.jsx(NoSearchResult, { message: props.noFilterMatchPage }) })] })] }));
|
|
1952
|
+
return (jsxRuntime.jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, style: { height: tableHeight }, children: [jsxRuntime.jsxs("table", { className: styles.table, "aria-label": "Data Grid", style: { width: table.getTotalSize(), minWidth: "100%" }, children: [jsxRuntime.jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsxRuntime.jsx(TableBody, { table: table, tableContainerRef: tableContainerRef })] }), jsxRuntime.jsxs(reactControlFlow.Switch, { when: true, children: [jsxRuntime.jsx(reactControlFlow.Case, { value: isLoading, children: jsxRuntime.jsx(Loading, { visibleColumns: table.getVisibleLeafColumns(), table: table }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: noItems, children: jsxRuntime.jsx(NoItemGrid, { message: props.noItemPage }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: noSearchResult, children: jsxRuntime.jsx(NoSearchResult, { message: props.noFilterMatchPage }) })] })] }));
|
|
1948
1953
|
};
|
|
1949
1954
|
|
|
1950
1955
|
const useCheckboxFilterStyles = reactComponents.makeStyles({
|
|
@@ -2404,7 +2409,7 @@ function AdvancedTable(props, ref) {
|
|
|
2404
2409
|
const touchSensor = core.useSensor(core.TouchSensor);
|
|
2405
2410
|
const keyboardSensor = core.useSensor(core.KeyboardSensor);
|
|
2406
2411
|
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 })] }) }));
|
|
2412
|
+
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
2413
|
}
|
|
2409
2414
|
const ForwardedAdvancedTable = React__namespace.forwardRef(AdvancedTable);
|
|
2410
2415
|
|
|
@@ -2422,6 +2427,23 @@ function useSkipper() {
|
|
|
2422
2427
|
return [shouldSkip, skip];
|
|
2423
2428
|
}
|
|
2424
2429
|
|
|
2430
|
+
const getTableData = (table) => {
|
|
2431
|
+
// format headers
|
|
2432
|
+
const { rows } = table.getCoreRowModel();
|
|
2433
|
+
// format rows key as a header and value as a row data
|
|
2434
|
+
const data = rows.map((row) => {
|
|
2435
|
+
const rowData = {};
|
|
2436
|
+
const cells = row.getVisibleCells();
|
|
2437
|
+
cells.forEach((cell) => {
|
|
2438
|
+
const columnId = cell.column.id;
|
|
2439
|
+
const value = cell.getValue();
|
|
2440
|
+
rowData[columnId] = value;
|
|
2441
|
+
});
|
|
2442
|
+
return rowData;
|
|
2443
|
+
});
|
|
2444
|
+
return data;
|
|
2445
|
+
};
|
|
2446
|
+
|
|
2425
2447
|
Object.defineProperty(exports, 'createColumnHelper', {
|
|
2426
2448
|
enumerable: true,
|
|
2427
2449
|
get: function () { return reactTable.createColumnHelper; }
|
|
@@ -2431,4 +2453,5 @@ exports.SelectRowCheckbox = SelectRowCheckbox;
|
|
|
2431
2453
|
exports.SelectRowRadio = SelectRowRadio;
|
|
2432
2454
|
exports.Table = ForwardedAdvancedTable;
|
|
2433
2455
|
exports.disableAllShorthand = disableAllShorthand;
|
|
2456
|
+
exports.getTableData = getTableData;
|
|
2434
2457
|
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
|
},
|
|
@@ -1593,7 +1592,7 @@ const HideColumnIcon = bundleIcon$1(EyeTrackingOffFilled, EyeTrackingOffRegular)
|
|
|
1593
1592
|
const GroupExpandIcon = bundleIcon$1(TextExpandFilled, TextExpandRegular);
|
|
1594
1593
|
const GroupCollapseIcon = bundleIcon$1(TextCollapseFilled, TextCollapseRegular);
|
|
1595
1594
|
function HeaderCell({ header, table, tabAttributes }) {
|
|
1596
|
-
var _a
|
|
1595
|
+
var _a;
|
|
1597
1596
|
const { column, id } = header;
|
|
1598
1597
|
const { isDragging, attributes, listeners, setNodeRef, transform, transition, } = useSortable({
|
|
1599
1598
|
id: id
|
|
@@ -1603,7 +1602,11 @@ function HeaderCell({ header, table, tabAttributes }) {
|
|
|
1603
1602
|
transition
|
|
1604
1603
|
};
|
|
1605
1604
|
const styles = useTableHeaderStyles();
|
|
1606
|
-
const isLeafHeaders = ((
|
|
1605
|
+
const isLeafHeaders = useMemo(() => {
|
|
1606
|
+
const leafCols = table.getAllLeafColumns();
|
|
1607
|
+
console.log("isLeafHeader");
|
|
1608
|
+
return !!(leafCols === null || leafCols === void 0 ? void 0 : leafCols.find(col => col.id === header.column.id));
|
|
1609
|
+
}, [table, header.column.id]);
|
|
1607
1610
|
const headerCellCombinedStyles = getHeaderCellPinningStyles(column, isDragging, dndStyle);
|
|
1608
1611
|
if (header.isPlaceholder) {
|
|
1609
1612
|
return (jsx("th", Object.assign({ colSpan: header.colSpan, className: styles.tHeadCell, style: headerCellCombinedStyles, ref: setNodeRef }, attributes, listeners, { children: jsx(Show, { when: header.column.getCanResize(), children: jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses$1(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }) })));
|
|
@@ -1624,10 +1627,10 @@ function HeaderCell({ header, table, tabAttributes }) {
|
|
|
1624
1627
|
if (!header.column.getCanGroup())
|
|
1625
1628
|
return;
|
|
1626
1629
|
header.column.getToggleGroupingHandler()();
|
|
1627
|
-
}, appearance: "transparent", className: styles.tHeadContentBtn, icon: (
|
|
1630
|
+
}, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_a = {
|
|
1628
1631
|
asc: (jsx("strong", { children: jsx(SortAscIcon, {}) })),
|
|
1629
1632
|
desc: (jsx("strong", { children: jsx(SortDescIcon, {}) })),
|
|
1630
|
-
}[header.column.getIsSorted()]) !== null &&
|
|
1633
|
+
}[header.column.getIsSorted()]) !== null && _a !== void 0 ? _a : undefined, iconPosition: "after", children: [jsx("strong", { children: columnName }), jsx(Show, { when: header.column.getIsGrouped(), children: jsx("strong", { children: jsx(GroupListRegular, {}) }) }), jsx(Show, { when: header.column.getIsFiltered(), children: jsx("strong", { children: jsx(FilterFilled, {}) }) }), jsx(Show, { when: header.column.getIsPinned(), children: jsx("strong", { children: jsx(PinRegular, {}) }) })] }) }) }), jsx(Show, { when: !!isLeafHeaders, children: jsx(HeaderMenu, { header: header, table: table }) })] }) })), jsx(Show, { when: header.column.getCanResize(), children: jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses$1(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }), jsx(Show, { when: !isLeafHeaders, children: jsx("div", { className: styles.tHeadNonLeafCellFakeBorder }) })] })));
|
|
1631
1634
|
}
|
|
1632
1635
|
function HeaderMenu(props) {
|
|
1633
1636
|
const { header, table } = props;
|
|
@@ -1696,27 +1699,29 @@ function HeaderRow(props) {
|
|
|
1696
1699
|
|
|
1697
1700
|
function TableHeader(props) {
|
|
1698
1701
|
const styles = useTableHeaderStyles();
|
|
1699
|
-
const { table, headerGroups
|
|
1702
|
+
const { table, headerGroups } = props;
|
|
1700
1703
|
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,
|
|
1704
|
+
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
1705
|
}
|
|
1703
1706
|
|
|
1704
1707
|
const useLoadingStyles = makeStyles({
|
|
1705
1708
|
invertedWrapper: {
|
|
1706
1709
|
backgroundColor: tokens.colorNeutralBackground1,
|
|
1707
1710
|
},
|
|
1708
|
-
row: Object.assign(
|
|
1711
|
+
row: Object.assign({ width: "100%", alignItems: "center", justifyContent: "space-between", display: "flex", position: "relative", paddingBottom: "10px", paddingTop: "10px" }, shorthands.gap("20px")),
|
|
1709
1712
|
});
|
|
1710
1713
|
|
|
1711
1714
|
const Loading = (props) => {
|
|
1712
|
-
|
|
1715
|
+
var _a;
|
|
1716
|
+
const { numberOfItems = 16, visibleColumns, table } = props;
|
|
1717
|
+
const selectionMode = ((_a = table.options.meta) === null || _a === void 0 ? void 0 : _a.rowSelectionMode) || "none";
|
|
1713
1718
|
const styles = useLoadingStyles();
|
|
1714
|
-
return (jsx("div", {
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1719
|
+
return (jsx("div", { style: { width: "100%" }, children: jsx(For, { each: [...Array(numberOfItems)], children: (rowIndex, index) => {
|
|
1720
|
+
return (jsxs(Skeleton, { className: styles.row, style: { width: "100%" }, children: [jsx(Show, { when: ["single", "multiple"].includes(selectionMode), children: jsx(SkeletonItem, { shape: "circle", size: 24, style: { width: "40px" } }, `${index}_select_row`) }), jsx(For, { each: visibleColumns || [], children: (column, i) => (jsx(SkeletonItem, { style: {
|
|
1721
|
+
minWidth: column.getSize(),
|
|
1722
|
+
width: "100%"
|
|
1723
|
+
} }, i)) })] }, `${rowIndex}_${index}`));
|
|
1724
|
+
} }) }));
|
|
1720
1725
|
};
|
|
1721
1726
|
|
|
1722
1727
|
const useNoItemGridStyles = makeStyles({
|
|
@@ -1922,7 +1927,7 @@ const TableContainer = (props) => {
|
|
|
1922
1927
|
const isLoading = props.isLoading && itemLength === 0;
|
|
1923
1928
|
const noItems = !isLoading && ((_a = props.data) === null || _a === void 0 ? void 0 : _a.length) === 0;
|
|
1924
1929
|
const noSearchResult = !isLoading && ((_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.length) > 0 && itemLength === 0;
|
|
1925
|
-
return (jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, style: { height: tableHeight }, children: [jsxs("table", { className: styles.table, "aria-label": "Data Grid", style: { width: table.getTotalSize(), minWidth: "100%" }, children: [jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsx(TableBody, { table: table, tableContainerRef: tableContainerRef })] }), jsxs(Switch, { when: true, children: [jsx(Case, { value: isLoading, children: jsx(Loading, {}) }), jsx(Case, { value: noItems, children: jsx(NoItemGrid, { message: props.noItemPage }) }), jsx(Case, { value: noSearchResult, children: jsx(NoSearchResult, { message: props.noFilterMatchPage }) })] })] }));
|
|
1930
|
+
return (jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, style: { height: tableHeight }, children: [jsxs("table", { className: styles.table, "aria-label": "Data Grid", style: { width: table.getTotalSize(), minWidth: "100%" }, children: [jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsx(TableBody, { table: table, tableContainerRef: tableContainerRef })] }), jsxs(Switch, { when: true, children: [jsx(Case, { value: isLoading, children: jsx(Loading, { visibleColumns: table.getVisibleLeafColumns(), table: table }) }), jsx(Case, { value: noItems, children: jsx(NoItemGrid, { message: props.noItemPage }) }), jsx(Case, { value: noSearchResult, children: jsx(NoSearchResult, { message: props.noFilterMatchPage }) })] })] }));
|
|
1926
1931
|
};
|
|
1927
1932
|
|
|
1928
1933
|
const useCheckboxFilterStyles = makeStyles({
|
|
@@ -2382,7 +2387,7 @@ function AdvancedTable(props, ref) {
|
|
|
2382
2387
|
const touchSensor = useSensor(TouchSensor);
|
|
2383
2388
|
const keyboardSensor = useSensor(KeyboardSensor);
|
|
2384
2389
|
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 })] }) }));
|
|
2390
|
+
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
2391
|
}
|
|
2387
2392
|
const ForwardedAdvancedTable = React.forwardRef(AdvancedTable);
|
|
2388
2393
|
|
|
@@ -2400,4 +2405,21 @@ function useSkipper() {
|
|
|
2400
2405
|
return [shouldSkip, skip];
|
|
2401
2406
|
}
|
|
2402
2407
|
|
|
2403
|
-
|
|
2408
|
+
const getTableData = (table) => {
|
|
2409
|
+
// format headers
|
|
2410
|
+
const { rows } = table.getCoreRowModel();
|
|
2411
|
+
// format rows key as a header and value as a row data
|
|
2412
|
+
const data = rows.map((row) => {
|
|
2413
|
+
const rowData = {};
|
|
2414
|
+
const cells = row.getVisibleCells();
|
|
2415
|
+
cells.forEach((cell) => {
|
|
2416
|
+
const columnId = cell.column.id;
|
|
2417
|
+
const value = cell.getValue();
|
|
2418
|
+
rowData[columnId] = value;
|
|
2419
|
+
});
|
|
2420
|
+
return rowData;
|
|
2421
|
+
});
|
|
2422
|
+
return data;
|
|
2423
|
+
};
|
|
2424
|
+
|
|
2425
|
+
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,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
type LoadingProps = {
|
|
1
|
+
import { Column, RowData, Table } from "@tanstack/react-table";
|
|
2
|
+
type LoadingProps<TItem extends RowData> = {
|
|
3
3
|
numberOfItems?: number;
|
|
4
|
-
|
|
4
|
+
visibleColumns: Column<TItem, unknown>[];
|
|
5
|
+
table: Table<TItem>;
|
|
5
6
|
};
|
|
6
|
-
export declare const Loading:
|
|
7
|
+
export declare const Loading: <TItem extends unknown>(props: LoadingProps<TItem>) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -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 = {
|