import type { PopoverProps } from '@blueprintjs/core'; import { Popover } from '@blueprintjs/core'; import type { Interpolation, Theme } from '@emotion/react'; import styled from '@emotion/styled'; import type { CSSProperties } from 'react'; import { useState } from 'react'; import type { ButtonProps } from 'react-science/ui'; import { Button } from 'react-science/ui'; const Container = styled.div>` display: flex; flex-direction: ${(props) => props.flexDirection}; gap: ${(props) => props.gap}px; button, a[role='button'] { border-radius: 50%; font-size: 10px; min-height: 16px; min-width: 16px; padding: 5px; } `; const HorizontalSeparator = styled.div` border-left: 1px solid #dedede; height: 10px; margin: auto 5px; width: 1px; `; const VerticalSeparator = styled.div` border-top: 1px solid #dedede; height: 1px; margin: 5px auto; width: 10px; `; interface PopoverButtonProps extends ButtonProps { title?: string; visible?: boolean; css?: Interpolation; } type ActionButtonProps = PopoverButtonProps | { elementType: 'separator' }; function isSeparator( element: ActionButtonProps, ): element is { elementType: 'separator' } { return 'elementType' in element && element.elementType === 'separator'; } type Direction = 'column' | 'row'; type AnchorTo = 'element' | 'cursor-x' | 'cursor-y' | 'cursor'; type AnchorPlacement = 'start' | 'end'; interface Position { x: number; y: number; } export interface ActionsButtonsPopoverProps extends Omit< PopoverProps, 'interactionKind' | 'content' | 'modifiers' | 'renderTarget' >, Partial { buttons: ActionButtonProps[]; contentStyle?: CSSProperties; direction?: Direction; space?: number; offsetX?: number; offsetY?: number; anchorTo?: AnchorTo; autoFlip?: boolean; anchorPlacement?: AnchorPlacement; } function ActionButton(props: ButtonProps) { return