@pagamio/frontend-commons-lib
Version:
Pagamio library for Frontend reusable components like the form engine and table container
12 lines (11 loc) • 2.24 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useMediaQueries } from '../../shared';
import CoreTable from './MantineCoreTable';
import TableToolbar from './TableToolbar';
const PagamioTable = ({ columns, data, isLoading, pagination, sorting, filtering, search, exportable = false, addButton = false, addText, onAdd, onClearFilters, handleSearchTable, showClearFilters = false, showApplyFilterButton = true, searctInputPlaceHolder, expandable = false, extraExportOptions, pdfExportOptions, xlsxExportOptions, csvExportOptions, renderExpandableComponent, onRowClick, rowClassName, ...props }) => {
const hasPagination = pagination?.enabled;
const { isSm, isXs } = useMediaQueries();
const isNarrow = isXs || isSm;
return (_jsxs("div", { className: "mt-2", children: [_jsx(TableToolbar, { searchable: search?.enabled ?? false, searchQuery: search?.searchQuery ?? '', onSearch: search?.onSearch ?? (() => { }), filters: filtering?.filters ?? [], appliedFilters: filtering?.appliedFilters ?? {}, onTableFilter: filtering?.onTableFilter ?? (() => { }), exportable: exportable, addButton: addButton, addText: addText, onAdd: onAdd ?? (() => { }), handleSearchTable: handleSearchTable, onClearFilters: onClearFilters, showClearFilters: showClearFilters, showApplyFilterButton: showApplyFilterButton, searctInputPlaceHolder: searctInputPlaceHolder, data: data, columns: columns, isNarrow: isNarrow, extraExportOptions: extraExportOptions, pdfExportOptions: pdfExportOptions, xlsxExportOptions: xlsxExportOptions, csvExportOptions: csvExportOptions, exportAll: props.exportAll, fetchData: props.fetchData }), _jsx("div", { className: "border border-gray-200 rounded-md overflow-hidden", children: _jsx(CoreTable, { columns: columns, data: data, isLoading: isLoading, onSort: sorting?.onSort, sortConfig: sorting?.sortConfig ?? null, multiSorting: sorting?.multiSorting || false, sortable: props.sortable, setSortBy: sorting?.setSortBy, setSortDir: sorting?.setSortDir, enablePagination: hasPagination, pagination: pagination, expandable: expandable, onRowClick: onRowClick, rowClassName: rowClassName, renderExpandableComponent: renderExpandableComponent, ...props }) })] }));
};
export default PagamioTable;