import { Card, PolymorphicRef } from '@cloud-ru/ds-card';
import { TruncateString } from '@cloud-ru/ds-truncate-string';
import { Typography } from '@cloud-ru/ds-typography';
import { withInnerRefSupport } from '@cloud-ru/ds-utils';
import cn from 'classnames';
import { ComponentPropsWithoutRef, ElementType, ReactElement } from 'react';
import { TEST_IDS } from '../../constants';
import { CardAction } from '../../helperComponents';
import styles from './styles.module.scss';
type BaseCardServiceProps = {
/** Заголовок карточки */
title: string;
/** Описание */
content: string;
/** Текст кнопки действия */
actionLabel: string;
/** Эмблема — передавайте `` или произвольный ReactElement */
emblem: ReactElement;
/** Неактивное состояние */
disabled?: boolean;
/** CSS-класс корневого элемента */
className?: string;
/** Support prop для тестов */
'data-test-id'?: string;
};
export type CardServiceProps = BaseCardServiceProps & {
/** Полиморфный элемент: `'div'`, `'a'`, `{Link}` и т.д. */
as?: T;
/** Ref на реальный DOM-элемент / инстанс */
innerRef?: PolymorphicRef;
} & Omit, keyof BaseCardServiceProps | 'as' | 'ref'>;
export function CardService({
title,
content,
actionLabel,
emblem,
disabled,
className,
as,
innerRef,
'data-test-id': dataTestId,
...rest
}: CardServiceProps): ReactElement | null {
return (
as={as}
innerRef={innerRef}
disabled={disabled}
interactive
className={cn(styles.root, className)}
data-test-id={dataTestId ?? TEST_IDS.cardService}
{...(rest as ComponentPropsWithoutRef)}
>
);
}
withInnerRefSupport(CardService);