import React, { useMemo } from 'react'; import { Badge, Card, Container, Icon, Stack, } from '@openedx/paragon'; import { useIntl } from '@edx/frontend-platform/i18n'; import messages from './messages'; import { getItemIcon, getComponentStyleColor } from '../../generic/block-type-utils'; import TagCount from '../../generic/tag-count'; import { BlockTypeLabel, type ContentHitTags, Highlight } from '../../search-manager'; type BaseComponentCardProps = { componentType: string; displayName: string; description: string; numChildren?: number; tags: ContentHitTags; actions: React.ReactNode; hasUnpublishedChanges?: boolean; onSelect: () => void }; const BaseComponentCard = ({ componentType, displayName, description, numChildren, tags, actions, onSelect, ...props } : BaseComponentCardProps) => { const tagCount = useMemo(() => { if (!tags) { return 0; } return (tags.level0?.length || 0) + (tags.level1?.length || 0) + (tags.level2?.length || 0) + (tags.level3?.length || 0); }, [tags]); const componentIcon = getItemIcon(componentType); const intl = useIntl(); return ( { if (['Enter', ' '].includes(e.key)) { onSelect(); } }} > } actions={ // Wrap the actions in a div to prevent the card from being clicked when the actions are clicked /* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */
e.stopPropagation()}>{actions}
} />

{props.hasUnpublishedChanges ? {intl.formatMessage(messages.unpublishedChanges)} : null}
); }; export default BaseComponentCard;