2023-12-15 17:34:50 +03:00
|
|
|
import clsx from 'clsx';
|
2024-01-04 19:30:10 +03:00
|
|
|
import type { TabProps as TabPropsImpl } from 'react-tabs';
|
|
|
|
import { Tab as TabImpl } from 'react-tabs';
|
2023-07-15 17:46:19 +03:00
|
|
|
|
2024-03-27 15:32:59 +03:00
|
|
|
import { globals } from '@/utils/constants';
|
2023-12-21 00:12:24 +03:00
|
|
|
|
2024-03-09 16:40:10 +03:00
|
|
|
import { CProps } from '../props';
|
|
|
|
|
|
|
|
interface TabLabelProps extends Omit<TabPropsImpl, 'children'>, CProps.Titled {
|
2023-12-28 14:04:44 +03:00
|
|
|
label?: string;
|
2023-08-27 15:39:49 +03:00
|
|
|
}
|
|
|
|
|
2024-03-09 16:40:10 +03:00
|
|
|
function TabLabel({ label, title, titleHtml, hideTitle, className, ...otherProps }: TabLabelProps) {
|
2023-07-15 17:46:19 +03:00
|
|
|
return (
|
2024-01-04 19:30:10 +03:00
|
|
|
<TabImpl
|
2023-12-28 14:04:44 +03:00
|
|
|
className={clsx(
|
2024-04-03 18:48:56 +03:00
|
|
|
'min-w-[5.5rem] h-full',
|
2023-12-28 14:04:44 +03:00
|
|
|
'px-2 py-1 flex justify-center',
|
|
|
|
'clr-tab',
|
2023-12-30 19:43:24 +03:00
|
|
|
'text-sm whitespace-nowrap font-controls',
|
2023-12-28 14:04:44 +03:00
|
|
|
'select-none hover:cursor-pointer',
|
|
|
|
className
|
|
|
|
)}
|
2024-03-27 15:32:59 +03:00
|
|
|
data-tooltip-id={!!title || !!titleHtml ? globals.tooltip : undefined}
|
2024-03-08 18:39:08 +03:00
|
|
|
data-tooltip-html={titleHtml}
|
2023-12-28 14:04:44 +03:00
|
|
|
data-tooltip-content={title}
|
2024-03-09 16:40:10 +03:00
|
|
|
data-tooltip-hidden={hideTitle}
|
2023-12-28 14:04:44 +03:00
|
|
|
{...otherProps}
|
|
|
|
>
|
|
|
|
{label}
|
2024-01-04 19:30:10 +03:00
|
|
|
</TabImpl>
|
2023-12-28 14:04:44 +03:00
|
|
|
);
|
2023-07-15 17:46:19 +03:00
|
|
|
}
|
|
|
|
|
2024-01-04 19:30:10 +03:00
|
|
|
TabLabel.tabsRole = 'Tab';
|
2023-07-15 17:46:19 +03:00
|
|
|
|
2024-01-04 19:30:10 +03:00
|
|
|
export default TabLabel;
|