UNPKG

@grafana/ui

Version:
77 lines (72 loc) 2.58 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var jsxRuntime = require('react/jsx-runtime'); var css = require('@emotion/css'); var ThemeContext = require('../../../themes/ThemeContext.cjs'); var utils = require('../utils.cjs'); var Table = require('./Table.cjs'); "use strict"; function ExpandedRow({ tableStyles, nestedData, rowIndex, width, cellHeight }) { const frames = nestedData.values; const subTables = []; const theme = ThemeContext.useTheme2(); const styles = ThemeContext.useStyles2(getStyles); let top = tableStyles.rowHeight + theme.spacing.gridSize; frames[rowIndex].forEach((nf, nfIndex) => { var _a, _b; const noHeader = !!((_b = (_a = nf.meta) == null ? void 0 : _a.custom) == null ? void 0 : _b.noHeader); const height = tableStyles.rowHeight * (nf.length + (noHeader ? 0 : 1)); const subTable = { height, paddingLeft: utils.EXPANDER_WIDTH, position: "absolute", top, backgroundColor: theme.colors.background.primary, color: theme.colors.text.primary }; top += height + theme.spacing.gridSize; subTables.push( /* @__PURE__ */ jsxRuntime.jsx("div", { style: subTable, children: /* @__PURE__ */ jsxRuntime.jsx( Table.Table, { data: nf, width: width - utils.EXPANDER_WIDTH, height: tableStyles.rowHeight * (nf.length + 1), noHeader, cellHeight } ) }, `subTable_${rowIndex}_${nfIndex}`) ); }); return /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles.subTables, children: subTables }); } const getStyles = (theme) => { return { subTables: css.css({ "&:before": { content: '""', position: "absolute", width: "1px", top: theme.spacing(5), left: theme.spacing(1), bottom: theme.spacing(2), background: theme.colors.border.medium } }) }; }; function getExpandedRowHeight(nestedData, rowIndex, tableStyles) { const frames = nestedData.values; const height = frames[rowIndex].reduce((acc, frame) => { var _a, _b; if (frame.length) { const noHeader = !!((_b = (_a = frame.meta) == null ? void 0 : _a.custom) == null ? void 0 : _b.noHeader); return acc + tableStyles.rowHeight * (frame.length + (noHeader ? 0 : 1)) + 8; } return acc; }, tableStyles.rowHeight); return height != null ? height : tableStyles.rowHeight; } exports.ExpandedRow = ExpandedRow; exports.getExpandedRowHeight = getExpandedRowHeight; //# sourceMappingURL=ExpandedRow.cjs.map