/** * @upsetjs/react * https://github.com/upsetjs/upsetjs * * Copyright (c) 2021 Samuel Gratzl */ import type { ISetLike } from '@upsetjs/model'; import React, { PropsWithChildren } from 'react'; import { generateSelectionName, generateSelectionOverlap } from '../../utils'; import type { KMapDataInfo } from '../derive/deriveDataDependent'; import type { KMapStyleInfo } from '../derive/deriveStyleDependent'; import KMapSelectionChart from './KMapSelectionChart'; export default function KMapSelection({ data, style, selection, hasHover, }: PropsWithChildren<{ style: KMapStyleInfo; data: KMapDataInfo; hasHover?: boolean; selection: ISetLike | null | readonly T[] | ((s: ISetLike) => number); }>) { const empty = style.emptySelection; const selectionOverlap = generateSelectionOverlap(selection, data.overlapGuesser, data.toElemKey); const selectionName = generateSelectionName(selection); return ( {(selection || empty) && ( )} ); }