import * as React from 'react'; import { observer } from 'mobx-react'; import classNames from 'classnames'; import styles from '../styles.module.scss'; import { caseCountsInParens, ComparisonGroup, getPatientIdentifiers, getSampleIdentifiers, MissingSamplesMessage, } from '../GroupComparisonUtils'; import ErrorIcon from '../../../shared/components/ErrorIcon'; import ComplexKeyMap from '../../../shared/lib/complexKeyDataStructures/ComplexKeyMap'; import { Sample } from 'cbioportal-ts-api-client'; import { SortableElement } from 'react-sortable-hoc'; import { getTextColor, renderGroupNameWithOrdinal } from '../OverlapUtils'; import { TOOLTIP_MOUSE_ENTER_DELAY_MS } from 'cbioportal-frontend-commons'; import * as ReactDOM from 'react-dom'; import { Popover, Overlay } from 'react-bootstrap'; import classnames from 'classnames'; import { action, observable, makeObservable } from 'mobx'; import autobind from 'autobind-decorator'; import { ButtonHTMLAttributes } from 'react'; export interface IGroupSelectorButtonProps { onClick: (name: string) => void; onClickDelete: (name: string) => void; deletable: boolean; isSelected: (name: string) => boolean; group: ComparisonGroup; sampleSet: ComplexKeyMap; excludedFromAnalysis: boolean; } @observer class GroupSelectorButton extends React.Component< IGroupSelectorButtonProps, {} > { @observable hovered = false; @observable.ref button: HTMLButtonElement | null; private hoverTimeout: any = null; constructor(props: IGroupSelectorButtonProps) { super(props); makeObservable(this); } @action.bound private buttonRef(button: HTMLButtonElement | null) { this.button = button; } @action.bound private onMouseClick() { this.hovered = false; } @action.bound private onMouseEnter() { this.hoverTimeout = setTimeout(() => { this.hovered = true; }, TOOLTIP_MOUSE_ENTER_DELAY_MS); } @action.bound private onMouseLeave() { this.hovered = false; clearTimeout(this.hoverTimeout); this.hoverTimeout = null; } @action.bound private onMouseDown() { this.hovered = false; } render() { const group = this.props.group; const selected = this.props.isSelected(group.name); const sampleIdentifiers = getSampleIdentifiers([group]); const patientIdentifiers = getPatientIdentifiers( sampleIdentifiers, this.props.sampleSet ); const button = ( ); return button; } } export default SortableElement(GroupSelectorButton);