Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
feat(UIKIT-1751,StaticDaysCalendar): Добавлена временная возможность …
Browse files Browse the repository at this point in the history
…включать интерактивность для тултипа (#1145)
  • Loading branch information
Ofigelov authored Sep 19, 2024
1 parent 980c379 commit e1147d8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ export type StaticDateCalendarButtonProps = Omit<
'variant' | 'title'
> & {
tooltipTitle?: ReactNode;
disableInteractive?: boolean;
};

export const StaticCalendarButton = forwardRef<
HTMLButtonElement,
StaticDateCalendarButtonProps
>(({ tooltipTitle, disabled, selected, ...props }, ref) => (
<StaticCalendarButtonTooltip title={tooltipTitle} isActive={!disabled}>
>(({ tooltipTitle, disabled, selected, disableInteractive, ...props }, ref) => (
<StaticCalendarButtonTooltip
title={tooltipTitle}
isActive={!disabled}
disableInteractive={disableInteractive}
>
<Wrapper
ref={ref}
variant={selected ? 'contained' : 'text'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { Tooltip } from '../../Tooltip';

type StaticCalendarButtonTooltipProps = {
title: ReactNode;
/**
* @default true
*/
disableInteractive?: boolean;
isActive: boolean;
children: JSX.Element;
};
Expand All @@ -12,10 +16,11 @@ export const StaticCalendarButtonTooltip = ({
children,
title,
isActive,
disableInteractive = true,
}: StaticCalendarButtonTooltipProps) => {
if (isActive) {
return (
<Tooltip title={title} disableInteractive>
<Tooltip title={title} disableInteractive={disableInteractive}>
{children}
</Tooltip>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ type MainButtonProps = Item & {
isNextItemInSelectedRange?: boolean;
onClick?: (date: Date) => void;
onDayHover?: (date?: Date) => void;
/**
* Пропс отвечающий за отключение возможности взаимодействия с тултипом
* @deprecated временное решение, и в последующем будет убрано
* @default true
*/
disableTooltipInteractive?: boolean;
};

export const DayButton = ({
onClick,
renderDayContent,
renderDayTooltipTitle,
onDayHover,
disableTooltipInteractive,
...props
}: MainButtonProps) => {
const {
Expand Down Expand Up @@ -57,6 +64,7 @@ export const DayButton = ({
isNextItemInSelectedRange={props.isNextItemInSelectedRange}
onMouseEnter={handleMouseEnter}
isInHoveredRange={props.isInHoveredRange}
disableInteractive={disableTooltipInteractive}
>
{handleRenderDayContent(props)}
</StaticCalendarGridButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export type StaticDaysCalendarProps = {
* @default по умолчанию рендерится день месяца
*/
renderDayContent?: (item: Item) => ReactNode;
/**
* Метод, решающий необходимость отключения возможности взаимодействия с тултипом
* @deprecated временное решение, и в последующем будет убрано
*/
checkDisableTooltipInteractive?: (item: Item) => boolean;
/**
* Флаг, отвечающий за необходимость скрытия дней, не относящихся к диапазону основного месяца
*/
Expand Down Expand Up @@ -65,6 +70,7 @@ const StaticDaysCalendarInner = memo(
selectedRanges,
hideOutOfAvailableRangeElements,
productionCalendarStorage,
checkDisableTooltipInteractive,
}: StaticDaysCalendarProps) => {
const id = useId();

Expand Down Expand Up @@ -116,6 +122,9 @@ const StaticDaysCalendarInner = memo(
onClick={onChange}
onDayHover={onDayHover}
renderDayTooltipTitle={renderDayTooltipTitle}
disableTooltipInteractive={checkDisableTooltipInteractive?.(
item,
)}
renderDayContent={renderDayContent}
/>
) : (
Expand Down

0 comments on commit e1147d8

Please sign in to comment.