UNPKG

@shopify/cli-kit

Version:

A set of utilities, interfaces, and models that are common across all the platform features

16 lines 1 kB
import { TokenizedText, tokenItemToString } from './TokenizedText.js'; import { unstyled } from '../../../../public/node/output.js'; import { Box } from 'ink'; import React from 'react'; const TabularData = ({ tabularData: data, firstColumnSubdued }) => { const columnWidths = data.reduce((acc, row) => { row.forEach((cell, index) => { acc[index] = Math.max(acc[index] ?? 0, unstyled(tokenItemToString(cell)).length); }); return acc; }, []); return (React.createElement(Box, { flexDirection: "column" }, data.map((row, index) => (React.createElement(Box, { key: index, flexDirection: "row", gap: 2 }, row.map((cell, index) => (React.createElement(Box, { key: index, width: columnWidths[index] ?? 0, flexShrink: index === 0 ? 0 : 1 }, React.createElement(TokenizedText, { item: index === 0 && firstColumnSubdued && typeof cell === 'string' ? { subdued: cell } : cell }))))))))); }; export { TabularData }; //# sourceMappingURL=TabularData.js.map