UNPKG

@grafana/ui

Version:
1 lines • 56.1 kB
{"version":3,"file":"TableNG.mjs","sources":["../../../../../src/components/Table/TableNG/TableNG.tsx"],"sourcesContent":["import 'react-data-grid/lib/styles.css';\n\nimport { clsx } from 'clsx';\nimport memoize from 'micro-memoize';\nimport { CSSProperties, Key, ReactNode, useCallback, useMemo, useRef, useState } from 'react';\nimport {\n Cell,\n CellRendererProps,\n DataGrid,\n DataGridHandle,\n DataGridProps,\n RenderCellProps,\n Renderers,\n RenderRowProps,\n Row,\n SortColumn,\n} from 'react-data-grid';\n\nimport {\n DataHoverClearEvent,\n DataHoverEvent,\n FALLBACK_COLOR,\n Field,\n FieldType,\n getDisplayProcessor,\n} from '@grafana/data';\nimport { Trans } from '@grafana/i18n';\nimport { FieldColorModeId, TableCellTooltipPlacement, TableFooterOptions } from '@grafana/schema';\n\nimport { useStyles2, useTheme2 } from '../../../themes/ThemeContext';\nimport { getTextColorForBackground as _getTextColorForBackground } from '../../../utils/colors';\nimport { Pagination } from '../../Pagination/Pagination';\nimport { PanelContext, usePanelContext } from '../../PanelChrome';\nimport { DataLinksActionsTooltip } from '../DataLinksActionsTooltip';\nimport { TableCellInspector, TableCellInspectorMode } from '../TableCellInspector';\nimport { TableCellDisplayMode } from '../types';\nimport { DataLinksActionsTooltipState } from '../utils';\n\nimport { getCellRenderer, getCellSpecificStyles } from './Cells/renderers';\nimport { HeaderCell } from './components/HeaderCell';\nimport { RowExpander } from './components/RowExpander';\nimport { SummaryCell } from './components/SummaryCell';\nimport { TableCellActions } from './components/TableCellActions';\nimport { TableCellTooltip } from './components/TableCellTooltip';\nimport { COLUMN, TABLE } from './constants';\nimport {\n useColumnResize,\n useColWidths,\n useFilteredRows,\n useHeaderHeight,\n usePaginatedRows,\n useRowHeight,\n useScrollbarWidth,\n useSortedRows,\n} from './hooks';\nimport {\n getCellActionStyles,\n getDefaultCellStyles,\n getGridStyles,\n getHeaderCellStyles,\n getLinkStyles,\n getMaxHeightCellStyles,\n getTooltipStyles,\n} from './styles';\nimport {\n TableNGProps,\n TableRow,\n TableSummaryRow,\n TableColumn,\n InspectCellProps,\n TableCellStyleOptions,\n FromFieldsResult,\n CellRootRenderer,\n} from './types';\nimport {\n applySort,\n canFieldBeColorized,\n calculateFooterHeight,\n createTypographyContext,\n displayJsonValue,\n extractPixelValue,\n frameToRecords,\n getAlignment,\n getApplyToRowBgFn,\n getCellColorInlineStylesFactory,\n getCellLinks,\n getCellOptions,\n getDefaultRowHeight,\n getDisplayName,\n getIsNestedTable,\n getJustifyContent,\n getVisibleFields,\n isCellInspectEnabled,\n predicateByName,\n shouldTextOverflow,\n shouldTextWrap,\n getSummaryCellTextAlign,\n parseStyleJson,\n IS_SAFARI_26,\n} from './utils';\n\nconst EXPANDED_COLUMN_KEY = 'expanded';\n\nexport function TableNG(props: TableNGProps) {\n const {\n cellHeight,\n data,\n disableSanitizeHtml,\n enablePagination = false,\n enableSharedCrosshair = false,\n enableVirtualization,\n frozenColumns = 0,\n getActions = () => [],\n height,\n initialSortBy,\n maxRowHeight: _maxRowHeight,\n noHeader,\n onCellFilterAdded,\n onColumnResize,\n onSortByChange,\n showTypeIcons,\n structureRev,\n timeRange,\n transparent,\n width,\n } = props;\n\n const theme = useTheme2();\n const styles = useStyles2(getGridStyles, enablePagination, transparent);\n const panelContext = usePanelContext();\n const userCanExecuteActions = useMemo(() => panelContext.canExecuteActions?.() ?? false, [panelContext]);\n\n const getCellActions = useCallback(\n (field: Field, rowIdx: number) => {\n if (!userCanExecuteActions) {\n return [];\n }\n return getActions(data, field, rowIdx);\n },\n [getActions, data, userCanExecuteActions]\n );\n\n const visibleFields = useMemo(() => getVisibleFields(data.fields), [data.fields]);\n const hasHeader = !noHeader;\n const hasFooter = useMemo(\n () => visibleFields.some((field) => Boolean(field.config.custom?.footer?.reducers?.length)),\n [visibleFields]\n );\n const footerHeight = useMemo(\n () => (hasFooter ? calculateFooterHeight(visibleFields) : 0),\n [hasFooter, visibleFields]\n );\n\n const resizeHandler = useColumnResize(onColumnResize);\n\n const rows = useMemo(() => frameToRecords(data), [data]);\n const hasNestedFrames = useMemo(() => getIsNestedTable(data.fields), [data]);\n const getTextColorForBackground = useMemo(() => memoize(_getTextColorForBackground, { maxSize: 1000 }), []);\n\n const {\n rows: filteredRows,\n filter,\n setFilter,\n crossFilterOrder,\n crossFilterRows,\n } = useFilteredRows(rows, data.fields, { hasNestedFrames });\n\n const {\n rows: sortedRows,\n sortColumns,\n setSortColumns,\n } = useSortedRows(filteredRows, data.fields, { hasNestedFrames, initialSortBy });\n\n const [inspectCell, setInspectCell] = useState<InspectCellProps | null>(null);\n const [tooltipState, setTooltipState] = useState<DataLinksActionsTooltipState>();\n const [expandedRows, setExpandedRows] = useState(() => new Set<number>());\n\n // vt scrollbar accounting for column auto-sizing\n\n const defaultRowHeight = useMemo(\n () => getDefaultRowHeight(theme, visibleFields, cellHeight),\n [theme, visibleFields, cellHeight]\n );\n const gridRef = useRef<DataGridHandle>(null);\n const scrollbarWidth = useScrollbarWidth(gridRef, height);\n const availableWidth = useMemo(\n () => (hasNestedFrames ? width - COLUMN.EXPANDER_WIDTH : width) - scrollbarWidth,\n [width, hasNestedFrames, scrollbarWidth]\n );\n const getCellColorInlineStyles = useMemo(() => getCellColorInlineStylesFactory(theme), [theme]);\n const applyToRowBgFn = useMemo(\n () => getApplyToRowBgFn(data.fields, getCellColorInlineStyles) ?? undefined,\n [data.fields, getCellColorInlineStyles]\n );\n const typographyCtx = useMemo(\n () =>\n createTypographyContext(\n theme.typography.fontSize,\n theme.typography.fontFamily,\n extractPixelValue(theme.typography.body.letterSpacing!) * theme.typography.fontSize\n ),\n [theme]\n );\n\n const [widths, numFrozenColsFullyInView] = useColWidths(visibleFields, availableWidth, frozenColumns);\n\n const headerHeight = useHeaderHeight({\n columnWidths: widths,\n fields: visibleFields,\n enabled: hasHeader,\n sortColumns,\n showTypeIcons: showTypeIcons ?? false,\n typographyCtx,\n });\n // the minimum max row height we should honor is a single line of text.\n const maxRowHeight = _maxRowHeight != null ? Math.max(TABLE.LINE_HEIGHT, _maxRowHeight) : undefined;\n const rowHeight = useRowHeight({\n columnWidths: widths,\n fields: visibleFields,\n hasNestedFrames,\n defaultHeight: defaultRowHeight,\n expandedRows,\n typographyCtx,\n maxHeight: maxRowHeight,\n });\n\n const {\n rows: paginatedRows,\n page,\n setPage,\n numPages,\n pageRangeStart,\n pageRangeEnd,\n smallPagination,\n } = usePaginatedRows(sortedRows, {\n enabled: enablePagination,\n width: availableWidth,\n height,\n footerHeight,\n headerHeight: hasHeader ? TABLE.HEADER_ROW_HEIGHT : 0,\n rowHeight,\n });\n\n const [footers, isUniformFooter] = useMemo(() => {\n const footers: Array<TableFooterOptions | undefined> = [];\n let isUniformFooter = true;\n let firstReducers: string[] | undefined;\n for (const field of visibleFields) {\n const footer = field.config?.custom?.footer;\n footers.push(footer);\n\n if (firstReducers === undefined && (footer?.reducers?.length ?? 0) > 0) {\n firstReducers = footer?.reducers; // store the reducers for the first visible array with a footer.\n } else if (firstReducers !== undefined) {\n // once we have a list of reducers, compare each subsequent footer's reducers to the first.\n const reducers: string[] | undefined = footer?.reducers;\n\n // ignore fields with no footer reducers.\n if (reducers?.length ?? 0 > 0) {\n // isUniformFooter is false if there are different numbers of reducers or if the reducers are not identical.\n if (reducers!.length !== firstReducers!.length || reducers!.some((r, idx) => firstReducers?.[idx] !== r)) {\n isUniformFooter = false;\n break;\n }\n }\n }\n }\n return [footers, isUniformFooter];\n }, [visibleFields]);\n\n // normalize the row height into a function which returns a number, so we avoid a bunch of conditionals during rendering.\n const rowHeightFn = useMemo((): ((row: TableRow) => number) => {\n if (typeof rowHeight === 'function') {\n return rowHeight;\n }\n if (typeof rowHeight === 'string') {\n return () => TABLE.MAX_CELL_HEIGHT;\n }\n return () => rowHeight;\n }, [rowHeight]);\n\n const renderRow = useMemo(\n () => renderRowFactory(data.fields, panelContext, expandedRows, enableSharedCrosshair),\n [data, enableSharedCrosshair, expandedRows, panelContext]\n );\n\n const commonDataGridProps = useMemo(\n () =>\n ({\n enableVirtualization: !IS_SAFARI_26 && enableVirtualization !== false && rowHeight !== 'auto',\n defaultColumnOptions: {\n minWidth: 50,\n resizable: true,\n sortable: true,\n // draggable: true,\n },\n onColumnResize: resizeHandler,\n onSortColumnsChange: (newSortColumns: SortColumn[]) => {\n setSortColumns(newSortColumns);\n onSortByChange?.(\n newSortColumns.map(({ columnKey, direction }) => ({\n displayName: columnKey,\n desc: direction === 'DESC',\n }))\n );\n },\n sortColumns,\n rowHeight,\n bottomSummaryRows: hasFooter ? [{}] : undefined,\n summaryRowHeight: footerHeight,\n headerRowClass: styles.headerRow,\n headerRowHeight: noHeader ? 0 : TABLE.HEADER_ROW_HEIGHT,\n }) satisfies Partial<DataGridProps<TableRow, TableSummaryRow>>,\n [\n enableVirtualization,\n hasFooter,\n resizeHandler,\n sortColumns,\n rowHeight,\n styles.headerRow,\n noHeader,\n setSortColumns,\n onSortByChange,\n footerHeight,\n ]\n );\n\n const buildNestedTableExpanderColumn = useCallback(\n (\n nestedColumns: TableColumn[],\n hasNestedHeaders: boolean,\n renderers: Renderers<TableRow, TableSummaryRow>\n ): TableColumn => ({\n key: EXPANDED_COLUMN_KEY,\n name: '',\n field: {\n name: '',\n type: FieldType.other,\n config: {},\n values: [],\n },\n cellClass(row) {\n if (row.__depth !== 0) {\n return styles.cellNested;\n }\n return;\n },\n colSpan(args) {\n return args.type === 'ROW' && args.row.__depth === 1 ? data.fields.length : 1;\n },\n renderCell: ({ row }) => {\n if (row.__depth === 0) {\n const rowIdx = row.__index;\n\n return (\n <RowExpander\n isExpanded={expandedRows.has(rowIdx)}\n onCellExpand={() => {\n if (expandedRows.has(rowIdx)) {\n expandedRows.delete(rowIdx);\n } else {\n expandedRows.add(rowIdx);\n }\n setExpandedRows(new Set(expandedRows));\n }}\n />\n );\n }\n\n // Type guard to check if data exists as it's optional\n const nestedData = row.data;\n if (!nestedData) {\n return null;\n }\n\n const expandedRecords = applySort(frameToRecords(nestedData), nestedData.fields, sortColumns);\n if (!expandedRecords.length) {\n return (\n <div className={styles.noDataNested}>\n <Trans i18nKey=\"grafana-ui.table.nested-table.no-data\">No data</Trans>\n </div>\n );\n }\n\n return (\n <DataGrid<TableRow, TableSummaryRow>\n {...commonDataGridProps}\n className={clsx(styles.grid, styles.gridNested)}\n headerRowClass={clsx(styles.headerRow, { [styles.displayNone]: !hasNestedHeaders })}\n headerRowHeight={hasNestedHeaders ? TABLE.HEADER_HEIGHT : 0}\n columns={nestedColumns}\n rows={expandedRecords}\n renderers={renderers}\n />\n );\n },\n width: COLUMN.EXPANDER_WIDTH,\n minWidth: COLUMN.EXPANDER_WIDTH,\n }),\n [commonDataGridProps, data.fields.length, expandedRows, sortColumns, styles]\n );\n\n const fromFields = useCallback(\n (f: Field[], widths: number[]): FromFieldsResult => {\n const result: FromFieldsResult = {\n columns: [],\n cellRootRenderers: {},\n };\n\n let lastRowIdx = -1;\n // shared when whole row will be styled by a single cell's color\n let rowCellStyle: Partial<CSSProperties> = {\n color: undefined,\n background: undefined,\n };\n\n f.forEach((field, i) => {\n const cellOptions = getCellOptions(field);\n const cellType = cellOptions.type;\n\n // make sure we use mappings exclusively if they exist, ignore default thresholds mode\n // we hack this by using the single color mode calculator\n if (cellType === TableCellDisplayMode.Pill && (field.config.mappings?.length ?? 0 > 0)) {\n field = {\n ...field,\n config: {\n ...field.config,\n color: {\n ...field.config.color,\n mode: FieldColorModeId.Fixed,\n fixedColor: field.config.color?.fixedColor ?? FALLBACK_COLOR,\n },\n },\n };\n field.display = getDisplayProcessor({ field, theme });\n }\n\n // attach JSONCell custom display function to JSONView cell type\n if (cellType === TableCellDisplayMode.JSONView || field.type === FieldType.other) {\n field.display = displayJsonValue(field);\n }\n\n // For some cells, \"aligning\" the cell will mean aligning the inline contents of the cell with\n // the text-align css property, and for others, we'll use justify-content to align the cell\n // contents with flexbox. We always just get both and provide both when styling the cell.\n const textAlign = getAlignment(field);\n const justifyContent = getJustifyContent(textAlign);\n const displayName = getDisplayName(field);\n const headerCellClass = getHeaderCellStyles(theme, justifyContent);\n const CellType = getCellRenderer(field, cellOptions);\n\n const cellInspect = isCellInspectEnabled(field);\n const showFilters = Boolean(field.config.filterable && onCellFilterAdded != null);\n const showActions = cellInspect || showFilters;\n const width = widths[i];\n\n // helps us avoid string cx and emotion per-cell\n const cellActionClassName = showActions\n ? clsx('table-cell-actions', getCellActionStyles(theme, textAlign))\n : undefined;\n\n const shouldOverflow =\n !IS_SAFARI_26 && rowHeight !== 'auto' && (shouldTextOverflow(field) || Boolean(maxRowHeight));\n const textWrap = rowHeight === 'auto' || shouldTextWrap(field);\n const canBeColorized = canFieldBeColorized(cellType, applyToRowBgFn);\n const cellStyleOptions: TableCellStyleOptions = {\n textAlign,\n textWrap,\n shouldOverflow,\n maxHeight: maxRowHeight,\n };\n\n const defaultCellStyles = getDefaultCellStyles(theme, cellStyleOptions);\n const cellSpecificStyles = getCellSpecificStyles(cellType, field, theme, cellStyleOptions);\n const linkStyles = getLinkStyles(theme, canBeColorized);\n const cellParentStyles = clsx(defaultCellStyles, linkStyles);\n const maxHeightClassName = maxRowHeight ? getMaxHeightCellStyles(theme, cellStyleOptions) : undefined;\n const styleFieldValue = field.config.custom?.styleField;\n const styleField = styleFieldValue ? data.fields.find(predicateByName(styleFieldValue)) : undefined;\n const styleFieldName = styleField ? getDisplayName(styleField) : undefined;\n const hasValidStyleField = Boolean(styleFieldName);\n\n // TODO: in future extend this to ensure a non-classic color scheme is set with AutoCell\n\n // this fires first\n const renderCellRoot = (key: Key, props: CellRendererProps<TableRow, TableSummaryRow>): ReactNode => {\n const rowIdx = props.row.__index;\n\n // meh, this should be cached by the renderRow() call?\n if (rowIdx !== lastRowIdx) {\n lastRowIdx = rowIdx;\n\n rowCellStyle.color = undefined;\n rowCellStyle.background = undefined;\n\n // generate shared styles for whole row\n if (applyToRowBgFn != null) {\n rowCellStyle = { ...rowCellStyle, ...applyToRowBgFn(rowIdx) };\n }\n }\n\n let style: CSSProperties = { ...rowCellStyle };\n if (canBeColorized) {\n const value = props.row[props.column.key];\n const displayValue = field.display!(value); // this fires here to get colors, then again to get rendered value?\n const cellColorStyles = getCellColorInlineStyles(cellOptions, displayValue, applyToRowBgFn != null);\n Object.assign(style, cellColorStyles);\n }\n if (hasValidStyleField) {\n style = { ...style, ...parseStyleJson(props.row[styleFieldName!]) };\n }\n\n return (\n <Cell\n key={key}\n {...props}\n className={clsx(\n props.className,\n cellParentStyles,\n cellSpecificStyles != null && { [cellSpecificStyles]: maxRowHeight == null }\n )}\n style={style}\n />\n );\n };\n\n result.cellRootRenderers[displayName] = renderCellRoot;\n\n const renderBasicCellContent = (props: RenderCellProps<TableRow, TableSummaryRow>): JSX.Element => {\n const rowIdx = props.row.__index;\n const value = props.row[props.column.key];\n // TODO: it would be nice to get rid of passing height down as a prop. but this value\n // is cached so the cost of calling for every cell is low.\n // NOTE: some cell types still require a height to be passed down, so that's why string-based\n // cell types are going to just pass down the max cell height as a numeric height for those cells.\n const height = rowHeightFn(props.row);\n const frame = data;\n\n let result = (\n <>\n <CellType\n cellOptions={cellOptions}\n frame={frame}\n field={field}\n height={height}\n rowIdx={rowIdx}\n theme={theme}\n value={value}\n width={width}\n timeRange={timeRange}\n cellInspect={cellInspect}\n showFilters={showFilters}\n getActions={getCellActions}\n disableSanitizeHtml={disableSanitizeHtml}\n getTextColorForBackground={getTextColorForBackground}\n />\n {showActions && (\n <TableCellActions\n field={field}\n value={value}\n displayName={displayName}\n cellInspect={cellInspect}\n showFilters={showFilters}\n className={cellActionClassName}\n setInspectCell={setInspectCell}\n onCellFilterAdded={onCellFilterAdded}\n />\n )}\n </>\n );\n\n if (maxRowHeight != null) {\n result = <div className={clsx(maxHeightClassName, cellSpecificStyles)}>{result}</div>;\n }\n\n return result;\n };\n\n // renderCellContent fires second.\n let renderCellContent = renderBasicCellContent;\n\n const tooltipFieldName = field.config.custom?.tooltip?.field;\n if (tooltipFieldName) {\n const tooltipField = data.fields.find(predicateByName(tooltipFieldName));\n if (tooltipField) {\n const tooltipDisplayName = getDisplayName(tooltipField);\n const tooltipCellOptions = getCellOptions(tooltipField);\n const tooltipFieldRenderer = getCellRenderer(tooltipField, tooltipCellOptions);\n\n const tooltipCellStyleOptions = {\n textAlign: getAlignment(tooltipField),\n textWrap: shouldTextWrap(tooltipField),\n shouldOverflow: false,\n maxHeight: maxRowHeight,\n } satisfies TableCellStyleOptions;\n const tooltipCanBeColorized = canFieldBeColorized(tooltipCellOptions.type, applyToRowBgFn);\n const tooltipDefaultStyles = getDefaultCellStyles(theme, tooltipCellStyleOptions);\n const tooltipSpecificStyles = getCellSpecificStyles(\n tooltipCellOptions.type,\n tooltipField,\n theme,\n tooltipCellStyleOptions\n );\n const tooltipLinkStyles = getLinkStyles(theme, tooltipCanBeColorized);\n const tooltipClasses = getTooltipStyles(theme, textAlign);\n\n const placement = field.config.custom?.tooltip?.placement ?? TableCellTooltipPlacement.Auto;\n const tooltipWidth =\n placement === TableCellTooltipPlacement.Left || placement === TableCellTooltipPlacement.Right\n ? tooltipField.config.custom?.width\n : width;\n\n const tooltipProps = {\n cellOptions: tooltipCellOptions,\n classes: tooltipClasses,\n className: clsx(\n tooltipClasses.tooltipContent,\n tooltipDefaultStyles,\n tooltipSpecificStyles,\n tooltipLinkStyles\n ),\n data,\n disableSanitizeHtml,\n field: tooltipField,\n getActions: getCellActions,\n getTextColorForBackground,\n gridRef,\n placement,\n renderer: tooltipFieldRenderer,\n tooltipField,\n theme,\n width: tooltipWidth,\n } satisfies Partial<React.ComponentProps<typeof TableCellTooltip>>;\n\n renderCellContent = (props: RenderCellProps<TableRow, TableSummaryRow>): JSX.Element => {\n // cached so we don't care about multiple calls.\n const tooltipHeight = rowHeightFn(props.row);\n let tooltipStyle: CSSProperties = { ...rowCellStyle };\n if (tooltipCanBeColorized) {\n const tooltipDisplayValue = tooltipField.display!(props.row[tooltipDisplayName]);\n const tooltipCellColorStyles = getCellColorInlineStyles(\n tooltipCellOptions,\n tooltipDisplayValue,\n applyToRowBgFn != null\n );\n Object.assign(tooltipStyle, tooltipCellColorStyles);\n }\n\n return (\n <TableCellTooltip\n {...tooltipProps}\n height={tooltipHeight}\n rowIdx={props.row.__index}\n style={tooltipStyle}\n >\n {renderBasicCellContent(props)}\n </TableCellTooltip>\n );\n };\n }\n }\n\n result.columns.push({\n field,\n key: displayName,\n name: displayName,\n width,\n headerCellClass,\n frozen: Math.min(frozenColumns, numFrozenColsFullyInView) > i,\n renderCell: renderCellContent,\n renderHeaderCell: ({ column, sortDirection }) => (\n <HeaderCell\n column={column}\n rows={rows}\n field={field}\n filter={filter}\n setFilter={setFilter}\n crossFilterOrder={crossFilterOrder}\n crossFilterRows={crossFilterRows}\n direction={sortDirection}\n showTypeIcons={showTypeIcons}\n />\n ),\n renderSummaryCell: () => (\n <SummaryCell\n rows={sortedRows}\n footers={footers}\n field={field}\n colIdx={i}\n textAlign={getSummaryCellTextAlign(textAlign, cellType)}\n rowLabel={isUniformFooter && i === 0}\n hideLabel={isUniformFooter && i !== 0}\n />\n ),\n });\n });\n\n return result;\n },\n [\n applyToRowBgFn,\n crossFilterOrder,\n crossFilterRows,\n data,\n disableSanitizeHtml,\n filter,\n footers,\n frozenColumns,\n getCellActions,\n getCellColorInlineStyles,\n getTextColorForBackground,\n isUniformFooter,\n maxRowHeight,\n numFrozenColsFullyInView,\n onCellFilterAdded,\n rows,\n rowHeight,\n rowHeightFn,\n setFilter,\n sortedRows,\n showTypeIcons,\n theme,\n timeRange,\n ]\n );\n\n // set up the first row's nested data and the nest field widths using useColWidths to avoid\n // unnecessary re-renders on re-size.\n const firstRowNestedData = useMemo(\n () => (hasNestedFrames ? rows.find((r) => r.data)?.data : undefined),\n [hasNestedFrames, rows]\n );\n const [nestedFieldWidths] = useColWidths(firstRowNestedData?.fields ?? [], availableWidth);\n\n const { columns, cellRootRenderers } = useMemo(() => {\n const result = fromFields(visibleFields, widths);\n\n // if nested frames are present, augment the columns to include the nested table expander column.\n if (!firstRowNestedData) {\n return result;\n }\n\n // pre-calculate renderRow and expandedColumns based on the first nested frame's fields.\n const hasNestedHeaders = firstRowNestedData.meta?.custom?.noHeader !== true;\n const renderRow = renderRowFactory(firstRowNestedData.fields, panelContext, expandedRows, enableSharedCrosshair);\n const { columns: nestedColumns, cellRootRenderers: nestedCellRootRenderers } = fromFields(\n firstRowNestedData.fields,\n nestedFieldWidths\n );\n\n const expanderCellRenderer: CellRootRenderer = (key, props) => <Cell key={key} {...props} />;\n result.cellRootRenderers[EXPANDED_COLUMN_KEY] = expanderCellRenderer;\n\n // If we have nested frames, we need to add a column for the row expansion\n result.columns.unshift(\n buildNestedTableExpanderColumn(nestedColumns, hasNestedHeaders, {\n renderRow,\n renderCell: (key, props) => nestedCellRootRenderers[props.column.key](key, props),\n })\n );\n\n return result;\n }, [\n buildNestedTableExpanderColumn,\n enableSharedCrosshair,\n expandedRows,\n firstRowNestedData,\n fromFields,\n nestedFieldWidths,\n panelContext,\n visibleFields,\n widths,\n ]);\n\n // invalidate columns on every structureRev change. this supports width editing in the fieldConfig.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const structureRevColumns = useMemo(() => columns, [columns, structureRev]);\n const renderCellRoot: CellRootRenderer = useCallback(\n (key, props) => cellRootRenderers[props.column.key](key, props),\n [cellRootRenderers]\n );\n\n // we need to have variables with these exact names for the localization to work properly\n const itemsRangeStart = pageRangeStart;\n const displayedEnd = pageRangeEnd;\n const numRows = sortedRows.length;\n\n let rendered = (\n <>\n <DataGrid<TableRow, TableSummaryRow>\n {...commonDataGridProps}\n ref={gridRef}\n className={styles.grid}\n columns={structureRevColumns}\n rows={paginatedRows}\n headerRowClass={clsx(styles.headerRow, { [styles.displayNone]: noHeader })}\n headerRowHeight={headerHeight}\n onCellClick={({ column, row }, { clientX, clientY, preventGridDefault, target }) => {\n // Note: could be column.field; JS says yes, but TS says no!\n const field = columns[column.idx].field;\n\n if (\n target instanceof HTMLElement &&\n // this walks up the tree to find either a faux link wrapper or the cell root\n // it then only proceeds if we matched the faux link wrapper\n target.closest('a[aria-haspopup], .rdg-cell')?.matches('a')\n ) {\n const rowIdx = row.__index;\n setTooltipState({\n coords: {\n clientX,\n clientY,\n },\n links: getCellLinks(field, rowIdx),\n actions: getCellActions(field, rowIdx),\n });\n\n preventGridDefault();\n }\n }}\n onCellKeyDown={\n hasNestedFrames\n ? (_, event) => {\n if (event.isDefaultPrevented()) {\n // skip parent grid keyboard navigation if nested grid handled it\n event.preventGridDefault();\n }\n }\n : null\n }\n renderers={{ renderRow, renderCell: renderCellRoot }}\n />\n\n {enablePagination && (\n <div className={styles.paginationContainer}>\n <Pagination\n className=\"table-ng-pagination\"\n currentPage={page + 1}\n numberOfPages={numPages}\n showSmallVersion={smallPagination}\n onNavigate={(toPage) => {\n setPage(toPage - 1);\n }}\n />\n {!smallPagination && (\n <div className={styles.paginationSummary}>\n {/* TODO: once TableRT is deprecated, we can update the localiziation\n string with the more consistent variable names */}\n <Trans i18nKey=\"grafana-ui.table.pagination-summary\">\n {{ itemsRangeStart }} - {{ displayedEnd }} of {{ numRows }} rows\n </Trans>\n </div>\n )}\n </div>\n )}\n\n {tooltipState && (\n <DataLinksActionsTooltip\n links={tooltipState.links ?? []}\n actions={tooltipState.actions}\n coords={tooltipState.coords}\n onTooltipClose={() => setTooltipState(undefined)}\n />\n )}\n\n {inspectCell && (\n <TableCellInspector\n mode={inspectCell.mode ?? TableCellInspectorMode.text}\n value={inspectCell.value}\n onDismiss={() => setInspectCell(null)}\n />\n )}\n </>\n );\n\n if (IS_SAFARI_26) {\n rendered = <div className={styles.safariWrapper}>{rendered}</div>;\n }\n\n return rendered;\n}\n\n/**\n * this is passed to the top-level `renderRow` prop on DataGrid. applies aria attributes and custom event handlers.\n */\nconst renderRowFactory =\n (fields: Field[], panelContext: PanelContext, expandedRows: Set<number>, enableSharedCrosshair: boolean) =>\n // eslint-disable-next-line react/display-name\n (key: React.Key, props: RenderRowProps<TableRow, TableSummaryRow>): React.ReactNode => {\n const { row } = props;\n const rowIdx = row.__index;\n const isExpanded = expandedRows.has(rowIdx);\n\n // Don't render non expanded child rows\n if (row.__depth === 1 && !isExpanded) {\n return null;\n }\n\n // Add aria-expanded to parent rows that have nested data\n if (row.data) {\n return <Row key={key} {...props} aria-expanded={isExpanded} />;\n }\n\n const handlers: Partial<typeof props> = {};\n if (enableSharedCrosshair) {\n const timeField = fields.find((f) => f.type === FieldType.time);\n if (timeField) {\n handlers.onMouseEnter = () => {\n panelContext.eventBus.publish(\n new DataHoverEvent({\n point: {\n time: timeField?.values[rowIdx],\n },\n })\n );\n };\n handlers.onMouseLeave = () => {\n panelContext.eventBus.publish(new DataHoverClearEvent());\n };\n }\n }\n\n return <Row key={key} {...props} {...handlers} />;\n };\n"],"names":["_a","_b","_c","getTextColorForBackground","_getTextColorForBackground","footers","isUniformFooter","widths","width","renderCellRoot","props","height","result","renderRow"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,MAAM,mBAAA,GAAsB,UAAA;AAErB,SAAS,QAAQ,KAAA,EAAqB;AAvG7C,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAwGE,EAAA,MAAM;AAAA,IACJ,UAAA;AAAA,IACA,IAAA;AAAA,IACA,mBAAA;AAAA,IACA,gBAAA,GAAmB,KAAA;AAAA,IACnB,qBAAA,GAAwB,KAAA;AAAA,IACxB,oBAAA;AAAA,IACA,aAAA,GAAgB,CAAA;AAAA,IAChB,UAAA,GAAa,MAAM,EAAC;AAAA,IACpB,MAAA;AAAA,IACA,aAAA;AAAA,IACA,YAAA,EAAc,aAAA;AAAA,IACd,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,cAAA;AAAA,IACA,cAAA;AAAA,IACA,aAAA;AAAA,IACA,YAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACF,GAAI,KAAA;AAEJ,EAAA,MAAM,QAAQ,SAAA,EAAU;AACxB,EAAA,MAAM,MAAA,GAAS,UAAA,CAAW,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