2024-06-07 20:17:03 +03:00
|
|
|
import type { TabProps as TabPropsImpl } from 'react-tabs';
|
|
|
|
import { Tab as TabImpl } from 'react-tabs';
|
2025-02-12 21:36:03 +03:00
|
|
|
import clsx from 'clsx';
|
2024-06-07 20:17:03 +03:00
|
|
|
|
2025-02-20 18:10:34 +03:00
|
|
|
import { globalIDs } from '@/utils/constants';
|
2024-06-07 20:17:03 +03:00
|
|
|
|
2025-02-20 20:22:05 +03:00
|
|
|
import { type Titled } from '../props';
|
2025-02-10 01:32:16 +03:00
|
|
|
|
2025-02-20 20:22:05 +03:00
|
|
|
interface TabLabelProps extends Omit<TabPropsImpl, 'children'>, Titled {
|
2024-11-21 15:09:31 +03:00
|
|
|
/** Label to display in the tab. */
|
2024-06-07 20:17:03 +03:00
|
|
|
label?: string;
|
|
|
|
}
|
|
|
|
|
2024-11-21 15:09:31 +03:00
|
|
|
/**
|
|
|
|
* Displays a tab header with a label.
|
|
|
|
*/
|
2025-03-20 11:33:19 +03:00
|
|
|
export function TabLabel({
|
|
|
|
label,
|
|
|
|
title,
|
|
|
|
titleHtml,
|
|
|
|
hideTitle,
|
|
|
|
className,
|
|
|
|
role = 'tab',
|
|
|
|
...otherProps
|
|
|
|
}: TabLabelProps) {
|
2024-06-07 20:17:03 +03:00
|
|
|
return (
|
|
|
|
<TabImpl
|
|
|
|
className={clsx(
|
2025-03-09 21:57:21 +03:00
|
|
|
'min-w-20 h-full',
|
2024-06-07 20:17:03 +03:00
|
|
|
'px-2 py-1 flex justify-center',
|
2025-04-12 21:47:46 +03:00
|
|
|
'cc-hover cc-animate-color duration-150',
|
2024-06-07 20:17:03 +03:00
|
|
|
'text-sm whitespace-nowrap font-controls',
|
|
|
|
'select-none hover:cursor-pointer',
|
2025-02-20 20:22:05 +03:00
|
|
|
'outline-hidden',
|
2024-06-07 20:17:03 +03:00
|
|
|
className
|
|
|
|
)}
|
|
|
|
tabIndex='-1'
|
2025-02-20 18:10:34 +03:00
|
|
|
data-tooltip-id={!!title || !!titleHtml ? globalIDs.tooltip : undefined}
|
2024-06-07 20:17:03 +03:00
|
|
|
data-tooltip-html={titleHtml}
|
|
|
|
data-tooltip-content={title}
|
|
|
|
data-tooltip-hidden={hideTitle}
|
2025-03-20 11:33:19 +03:00
|
|
|
role={role}
|
2024-06-07 20:17:03 +03:00
|
|
|
{...otherProps}
|
|
|
|
>
|
|
|
|
{label}
|
|
|
|
</TabImpl>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TabLabel.tabsRole = 'Tab';
|