Changeset View
Changeset View
Standalone View
Standalone View
web/utils/typeahead-utils.js
Show First 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | return ( | ||||
className={buttonClasses} | className={buttonClasses} | ||||
> | > | ||||
<span>@{actionButtonContent}</span> | <span>@{actionButtonContent}</span> | ||||
</Button> | </Button> | ||||
); | ); | ||||
}); | }); | ||||
} | } | ||||
function getTypeaheadOverlayScroll( | |||||
currentScrollTop: number, | |||||
chosenActionPosition: number, | |||||
): number { | |||||
const upperButtonBoundary = chosenActionPosition * typeaheadStyle.rowHeight; | |||||
const lowerButtonBoundary = | |||||
(chosenActionPosition + 1) * typeaheadStyle.rowHeight; | |||||
if (upperButtonBoundary < currentScrollTop) { | |||||
return upperButtonBoundary; | |||||
} else if ( | |||||
lowerButtonBoundary - typeaheadStyle.tooltipMaxHeight > | |||||
currentScrollTop | |||||
) { | |||||
return ( | |||||
lowerButtonBoundary + | |||||
typeaheadStyle.tooltipVerticalPadding - | |||||
typeaheadStyle.tooltipMaxHeight | |||||
); | |||||
} | |||||
return currentScrollTop; | |||||
} | |||||
function getTypeaheadTooltipPosition( | function getTypeaheadTooltipPosition( | ||||
textarea: HTMLTextAreaElement, | textarea: HTMLTextAreaElement, | ||||
actionsLength: number, | actionsLength: number, | ||||
textBeforeAtSymbol: string, | textBeforeAtSymbol: string, | ||||
): TooltipPosition { | ): TooltipPosition { | ||||
const { caretTopOffset, caretLeftOffset } = getCaretOffsets( | const { caretTopOffset, caretLeftOffset } = getCaretOffsets( | ||||
textarea, | textarea, | ||||
textBeforeAtSymbol, | textBeforeAtSymbol, | ||||
Show All 19 Lines | ): TooltipPosition { | ||||
return { top, left }; | return { top, left }; | ||||
} | } | ||||
export { | export { | ||||
webTypeaheadRegex, | webTypeaheadRegex, | ||||
getCaretOffsets, | getCaretOffsets, | ||||
getTypeaheadTooltipActions, | getTypeaheadTooltipActions, | ||||
getTypeaheadTooltipButtons, | getTypeaheadTooltipButtons, | ||||
getTypeaheadOverlayScroll, | |||||
getTypeaheadTooltipPosition, | getTypeaheadTooltipPosition, | ||||
}; | }; |