UNPKG

@grafana/ui

Version:
58 lines (53 loc) 2.2 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var jsxRuntime = require('react/jsx-runtime'); var React = require('react'); var data = require('@grafana/data'); var e2eSelectors = require('@grafana/e2e-selectors'); var FooterCell = require('../Cells/FooterCell.cjs'); "use strict"; function FooterRow(props) { const { totalColumnsWidth, footerGroups, isPaginationVisible, tableStyles } = props; const e2eSelectorsTable = e2eSelectors.selectors.components.Panels.Visualization.Table; return /* @__PURE__ */ jsxRuntime.jsx( "div", { style: { position: isPaginationVisible ? "relative" : "absolute", width: totalColumnsWidth ? `${totalColumnsWidth}px` : "100%", bottom: "0px" }, children: footerGroups.map((footerGroup) => { const { key, ...footerGroupProps } = footerGroup.getFooterGroupProps(); return /* @__PURE__ */ React.createElement("div", { className: tableStyles.tfoot, ...footerGroupProps, key, "data-testid": e2eSelectorsTable.footer }, footerGroup.headers.map((column) => renderFooterCell(column, tableStyles))); }) } ); } function renderFooterCell(column, tableStyles) { var _a; const { key, ...footerProps } = column.getHeaderProps(); if (!footerProps) { return null; } footerProps.style = (_a = footerProps.style) != null ? _a : {}; footerProps.style.position = "absolute"; footerProps.style.justifyContent = column.justifyContent; return /* @__PURE__ */ jsxRuntime.jsx("div", { className: tableStyles.headerCell, ...footerProps, children: column.render("Footer") }, key); } function getFooterValue(index, footerValues, isCountRowsSet) { if (footerValues === void 0) { return FooterCell.EmptyCell; } if (isCountRowsSet) { if (footerValues[index] === void 0) { return FooterCell.EmptyCell; } const key = data.fieldReducers.get(data.ReducerID.count).name; return FooterCell.FooterCell({ value: [{ [key]: String(footerValues[index]) }] }); } return FooterCell.FooterCell({ value: footerValues[index] }); } exports.FooterRow = FooterRow; exports.getFooterValue = getFooterValue; //# sourceMappingURL=FooterRow.cjs.map