pagamio-frontend-commons-lib
Version:
Pagamio library for Frontend reusable components like the form engine and table container
16 lines (15 loc) • 1.93 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { HiPlusSm } from 'react-icons/hi';
import { FilterComponent, IconButton } from '../../components';
import ExportDropdown from './ExportButton';
const TableToolbar = ({ searchable, searchQuery, onSearch, filters = [], appliedFilters, exportable, columns, data, onTableFilter = () => { }, addButton, addText, searctInputPlaceHolder, onAdd, handleSearchTable, handleApplyFilters, onClearFilters = () => { }, showClearFilters = false, showApplyFilterButton = true, isNarrow, }) => {
const handleFilter = (columnKey, value) => {
onTableFilter(columnKey, value ?? '');
};
return (_jsx(FilterComponent, { filters: filters.map((filterObj) => ({
name: filterObj.columnKey,
type: 'select',
options: filterObj.options,
})), searctInputPlaceHolder: searctInputPlaceHolder, showClearFilters: showClearFilters, showApplyFilterButton: showApplyFilterButton, selectedFilters: appliedFilters, handleFilterChange: (name, value) => handleFilter(name, value), handleApplyFilters: handleApplyFilters ?? handleSearchTable, resetFilters: onClearFilters, showSearch: searchable, searchQuery: searchQuery, onSearch: onSearch, isNarrow: isNarrow, children: _jsxs("div", { className: isNarrow ? 'flex flex-col items-stretch space-y-2 pt-5' : 'flex items-center flex-wrap gap-2', children: [exportable && (_jsx("div", { className: isNarrow ? 'w-full' : 'flex-grow', children: _jsx(ExportDropdown, { containerClassName: "w-full", columns: columns, data: data, buttonClassName: "h-10" }) })), addButton && (_jsx("div", { className: isNarrow ? 'w-full' : 'flex-grow', children: _jsx(IconButton, { onClick: onAdd, icon: HiPlusSm, label: "add-new-entry", className: "bg-core-add items-center hover:bg-core-add-hover w-full text-nowrap", children: addText ?? 'Add New Entry' }) }))] }) }));
};
export default TableToolbar;