@pagamio/frontend-commons-lib 0.8.311 → 0.8.312
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { MantineReactTable, useMantineReactTable } from 'mantine-react-table';
|
|
3
3
|
import { HiPlusSm } from 'react-icons/hi';
|
|
4
|
-
import { useMemo, useState } from 'react';
|
|
4
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import { FilterComponent, IconButton } from '../../components';
|
|
6
6
|
import { useMediaQueries } from '../../shared';
|
|
7
7
|
import { getDefaultTableOptions } from './Defaults';
|
|
@@ -62,6 +62,32 @@ function CustomToolbar({ filters, appliedFilters, onFilterChange, onApply, onCle
|
|
|
62
62
|
// ─── PagamioTable Component ──────────────────────────────────────────
|
|
63
63
|
const PagamioTable = ({ columns, data, isLoading = false, rowCount, sorting, pagination, filtering, search, onRowClick, rowClassName, expandable = false, renderDetailPanel, toolbar, toolbarMode = 'custom', enableColumnResizing, enableColumnPinning, enableColumnOrdering, enableColumnFilters, enableHiding, enableRowSelection, enableRowActions, enableRowVirtualization, enableGrouping, enableEditing, enableDensityToggle, enableFullScreenToggle, enableClickToCopy, enableRowNumbers, enableMultiSort, enableStickyHeader, enableStickyFooter, editDisplayMode, onEditingRowSave, onEditingRowCancel, renderRowActions, renderRowActionMenuItems, positionActionsColumn, renderTopToolbarCustomActions, renderBottomToolbarCustomActions, layoutMode, defaultColumn, mantineTableOptions, }) => {
|
|
64
64
|
const [expanded, setExpanded] = useState({});
|
|
65
|
+
const tableRef = useRef(null);
|
|
66
|
+
const applyTableHeight = (el) => {
|
|
67
|
+
const mrtContainer = el.querySelector('.mrt-table-container');
|
|
68
|
+
if (!mrtContainer)
|
|
69
|
+
return;
|
|
70
|
+
const containerTop = mrtContainer.getBoundingClientRect().top;
|
|
71
|
+
const offset = Math.round(containerTop + 68); // 52 MRT pagination + 16 gap
|
|
72
|
+
mrtContainer.style.setProperty('max-height', `calc(100vh - ${offset}px)`, 'important');
|
|
73
|
+
};
|
|
74
|
+
// Runs after every render (no deps), always after MRT's own layout effect.
|
|
75
|
+
useLayoutEffect(() => {
|
|
76
|
+
if (tableRef.current)
|
|
77
|
+
applyTableHeight(tableRef.current);
|
|
78
|
+
});
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
const el = tableRef.current;
|
|
81
|
+
if (!el)
|
|
82
|
+
return;
|
|
83
|
+
const resizeObserver = new ResizeObserver(() => applyTableHeight(el));
|
|
84
|
+
resizeObserver.observe(document.documentElement);
|
|
85
|
+
window.addEventListener('resize', () => applyTableHeight(el));
|
|
86
|
+
return () => {
|
|
87
|
+
resizeObserver.disconnect();
|
|
88
|
+
window.removeEventListener('resize', () => applyTableHeight(el));
|
|
89
|
+
};
|
|
90
|
+
}, []);
|
|
65
91
|
// Process columns (handle showHeader: false)
|
|
66
92
|
const processedColumns = useMemo(() => processColumns(columns), [columns]);
|
|
67
93
|
// Convert our SortConfig to MRT's SortingState
|
|
@@ -168,6 +194,12 @@ const PagamioTable = ({ columns, data, isLoading = false, rowCount, sorting, pag
|
|
|
168
194
|
// Layout
|
|
169
195
|
...(layoutMode && { layoutMode }),
|
|
170
196
|
...(defaultColumn && { defaultColumn }),
|
|
197
|
+
mantineTableContainerProps: {
|
|
198
|
+
style: {
|
|
199
|
+
border: 'transparent',
|
|
200
|
+
borderRadius: '4px',
|
|
201
|
+
},
|
|
202
|
+
},
|
|
171
203
|
// Row interaction styling
|
|
172
204
|
mantineTableBodyRowProps: ({ row }) => ({
|
|
173
205
|
onClick: onRowClick ? (event) => handleRowClick(row, event) : undefined,
|
|
@@ -179,6 +211,6 @@ const PagamioTable = ({ columns, data, isLoading = false, rowCount, sorting, pag
|
|
|
179
211
|
});
|
|
180
212
|
// ── Toolbar rendering ──────────────────────────────────────────────
|
|
181
213
|
const showCustomToolbar = toolbarMode === 'custom' && (!!toolbar || !!search || !!filtering);
|
|
182
|
-
return (_jsxs("div", { children: [showCustomToolbar && (_jsx(CustomToolbar, { filters: toolbar?.filters ?? [], appliedFilters: filtering?.appliedFilters ?? {}, onFilterChange: filtering?.onFilterChange ?? (() => { }), onApply: filtering?.onApply ?? (() => { }), onClearFilters: toolbar?.onClearFilters, showClearFilters: toolbar?.showClearFilters ?? false, showApplyFilterButton: toolbar?.showApplyFilterButton ?? true, searchEnabled: !!search, searchQuery: search?.query ?? '', onSearch: search?.onChange ?? (() => { }), searchPlaceholder: search?.placeholder, exportConfig: toolbar?.export, columns: columns, data: data, addButton: toolbar?.addButton, addText: toolbar?.addText, onAdd: toolbar?.onAdd })), _jsx("div", { className: "border border-border rounded-md overflow-hidden", children: _jsx(MantineReactTable, { table: table }) })] }));
|
|
214
|
+
return (_jsxs("div", { children: [showCustomToolbar && (_jsx(CustomToolbar, { filters: toolbar?.filters ?? [], appliedFilters: filtering?.appliedFilters ?? {}, onFilterChange: filtering?.onFilterChange ?? (() => { }), onApply: filtering?.onApply ?? (() => { }), onClearFilters: toolbar?.onClearFilters, showClearFilters: toolbar?.showClearFilters ?? false, showApplyFilterButton: toolbar?.showApplyFilterButton ?? true, searchEnabled: !!search, searchQuery: search?.query ?? '', onSearch: search?.onChange ?? (() => { }), searchPlaceholder: search?.placeholder, exportConfig: toolbar?.export, columns: columns, data: data, addButton: toolbar?.addButton, addText: toolbar?.addText, onAdd: toolbar?.onAdd })), _jsx("div", { ref: tableRef, className: "border border-border rounded-md overflow-hidden", children: _jsx(MantineReactTable, { table: table }) })] }));
|
|
183
215
|
};
|
|
184
216
|
export default PagamioTable;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagamio/frontend-commons-lib",
|
|
3
3
|
"description": "Pagamio library for Frontend reusable components like the form engine and table container",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.312",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": false
|