2024-06-07 20:17:03 +03:00
|
|
|
import clsx from 'clsx';
|
|
|
|
import type { TabProps as TabPropsImpl } from 'react-tabs';
|
|
|
|
import { Tab as TabImpl } from 'react-tabs';
|
|
|
|
|
|
|
|
import { globals } from '@/utils/constants';
|
|
|
|
|
|
|
|
import { CProps } from '../props';
|
|
|
|
|
|
|
|
interface TabLabelProps extends Omit<TabPropsImpl, 'children'>, CProps.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.
|
|
|
|
*/
|
2024-06-07 20:17:03 +03:00
|
|
|
function TabLabel({ label, title, titleHtml, hideTitle, className, ...otherProps }: TabLabelProps) {
|
|
|
|
return (
|
|
|
|
<TabImpl
|
|
|
|
className={clsx(
|
|
|
|
'min-w-[5.5rem] h-full',
|
|
|
|
'px-2 py-1 flex justify-center',
|
2024-12-17 11:37:42 +03:00
|
|
|
'clr-hover bg-prim-200 cc-animate-color',
|
2024-06-07 20:17:03 +03:00
|
|
|
'text-sm whitespace-nowrap font-controls',
|
|
|
|
'select-none hover:cursor-pointer',
|
|
|
|
'outline-none',
|
|
|
|
className
|
|
|
|
)}
|
|
|
|
tabIndex='-1'
|
|
|
|
data-tooltip-id={!!title || !!titleHtml ? globals.tooltip : undefined}
|
|
|
|
data-tooltip-html={titleHtml}
|
|
|
|
data-tooltip-content={title}
|
|
|
|
data-tooltip-hidden={hideTitle}
|
|
|
|
{...otherProps}
|
|
|
|
>
|
|
|
|
{label}
|
|
|
|
</TabImpl>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TabLabel.tabsRole = 'Tab';
|
|
|
|
|
|
|
|
export default TabLabel;
|