import { Table, flexRender } from '@tanstack/react-table'; import { EntryId, SupportedEntry } from 'ontime-types'; import { colourToHex, cssOrHexToColour } from 'ontime-utils'; import { CSSProperties, memo, useMemo } from 'react'; import { IoEllipsisHorizontal } from 'react-icons/io5'; import IconButton from '../../../../common/components/buttons/IconButton'; import type { ExtendedEntry } from '../../../../common/utils/rundownMetadata'; import { cx, enDash, getAccessibleColour } from '../../../../common/utils/styleUtils'; import { AppMode } from '../../../../ontimeConfig'; import { useCuesheetTableMenu } from '../cuesheet-table-menu/useCuesheetTableMenu'; import style from './MilestoneRow.module.scss'; interface MilestoneRowProps { entryId: EntryId; isPast: boolean; parentBgColour?: string; parentId: EntryId | null; colour: string; rowId: string; rowIndex: number; table: Table; injectedStyles?: CSSProperties; hasCursor?: boolean; } export default memo(MilestoneRow); function MilestoneRow({ entryId, isPast, parentBgColour, parentId, colour, rowId, rowIndex, hasCursor, table, injectedStyles, ...virtuosoProps }: MilestoneRowProps) { const { cuesheetMode, hideIndexColumn } = table.options.meta?.options ?? { cuesheetMode: AppMode.Edit, hideIndexColumn: false, }; const openMenu = useCuesheetTableMenu((store) => store.openMenu); const rowBgColour = useMemo(() => { if (!colour) return undefined; const accessibleBg = cssOrHexToColour(getAccessibleColour(colour).backgroundColor); if (accessibleBg === null) return undefined; return colourToHex({ ...accessibleBg, alpha: accessibleBg.alpha * 0.25 }); }, [colour]); return ( {cuesheetMode === AppMode.Edit && ( { const rect = e.currentTarget.getBoundingClientRect(); const yPos = 8 + rect.y + rect.height / 2; openMenu({ x: rect.x, y: yPos }, entryId, SupportedEntry.Milestone, rowIndex, parentId, null); }} > )} {!hideIndexColumn && ( {enDash} )} {table .getRow(rowId) .getVisibleCells() .map((cell) => { const canRender = cell.column.id !== 'duration' && cell.column.id !== 'timeStart' && cell.column.id !== 'timeEnd'; return ( {canRender && flexRender(cell.column.columnDef.cell, cell.getContext())} ); })} ); }