import React, { JSX } from 'react'; import styled from 'styled-components'; import type { CatalogEntityConfig, EntitiesCatalogConfig } from '@redocly/config'; import type { ListType } from '@redocly/theme/core/types'; import type { BffCatalogRelatedEntity } from '@redocly/theme/core/types'; import { ArrowDownIcon } from '@redocly/theme/icons/ArrowDownIcon/ArrowDownIcon'; import { LoadMore } from '@redocly/theme/components/LoadMore/LoadMore'; import { CatalogColumn, CatalogTableView, } from '@redocly/theme/components/Catalog/CatalogTableView/CatalogTableView'; import { HighlightContext } from '@redocly/theme/components/Catalog/CatalogHighlight'; import { CatalogEntitiesEmptyState } from '@redocly/theme/components/Catalog/CatalogEntitiesEmptyState'; export type CatalogEntityRelationsTableContentProps = { entitiesCatalogConfig: EntitiesCatalogConfig; catalogConfig: CatalogEntityConfig; relations: BffCatalogRelatedEntity[]; query: { fetchNextPage: () => void; isFetchingNextPage: boolean; }; searchQuery: string; columns: CatalogColumn[]; sortOption: string | null; handleSortClick: (sortKey: string, direction: 'asc' | 'desc') => void; isColumnSorted: (sortKey: string, direction: 'asc' | 'desc') => boolean; shouldShowLoadMore: boolean; listType?: ListType; onRowClick: (entity: BffCatalogRelatedEntity) => void; }; export function CatalogEntityRelationsTableContent({ entitiesCatalogConfig, catalogConfig, relations, query, searchQuery, columns, sortOption, handleSortClick, isColumnSorted, shouldShowLoadMore, listType, onRowClick, }: CatalogEntityRelationsTableContentProps): JSX.Element { return ( {relations.length > 0 ? ( ) : ( )} {shouldShowLoadMore && ( } onClick={query.fetchNextPage} disabled={query.isFetchingNextPage} blinking={query.isFetchingNextPage} label={query.isFetchingNextPage ? 'Loading...' : 'Load More'} /> )} ); } const TABLE_SCROLL_MIN_WIDTH_PX = 608; const TableContentWrapper = styled.div` min-width: 0; /* Constrain width so table overflow-x scroll works inside tabs */ `;