UNPKG

@redocly/theme

Version:

Shared UI components lib

22 lines 975 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useCatalogTableHeaderCellActions = useCatalogTableHeaderCellActions; function useCatalogTableHeaderCellActions({ column, currentSortOption, handleSortClick, isColumnSorted, }) { const sortKey = column.sortKey; const isUpActive = Boolean(sortKey && (currentSortOption ? currentSortOption === sortKey : isColumnSorted(sortKey, 'desc'))); const isDownActive = Boolean(sortKey && (currentSortOption ? currentSortOption === `-${sortKey}` : isColumnSorted(sortKey, 'asc'))); const handleCellClick = () => { if (!column.sortable || !sortKey) return; if (isDownActive) { handleSortClick(sortKey, 'desc'); } else { handleSortClick(sortKey, 'asc'); } }; return { handleCellClick, sortKey, isUpActive, isDownActive }; } //# sourceMappingURL=use-catalog-table-header-cell-actions.js.map