2 var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
5 Object.defineProperty(exports, "__esModule", { value: true });
6 exports.drawTable = void 0;
7 const string_width_1 = __importDefault(require("string-width"));
8 const drawBorder_1 = require("./drawBorder");
9 const drawContent_1 = require("./drawContent");
10 const drawHeader_1 = require("./drawHeader");
11 const drawRow_1 = require("./drawRow");
12 const utils_1 = require("./utils");
13 const drawTable = (rows, columnWidths, rowHeights, config) => {
14 const { drawHorizontalLine, singleLine, } = config;
15 const contents = (0, utils_1.groupBySizes)(rows, rowHeights).map((group) => {
16 return group.map((row) => {
17 return (0, drawRow_1.drawRow)(row, config);
21 // assume that topLeft/right border have width = 1
22 const headerWidth = (0, string_width_1.default)((0, drawRow_1.drawRow)(rows[0], config)) - 2 -
23 config.header.paddingLeft - config.header.paddingRight;
24 const header = (0, drawHeader_1.drawHeader)(headerWidth, config);
25 contents.unshift(header);
27 return (0, drawContent_1.drawContent)(contents, {
28 drawSeparator: (index, size) => {
30 if (index === 0 || index === size) {
31 return drawHorizontalLine(index, size);
33 return !singleLine && drawHorizontalLine(index, size);
35 separatorGetter: (0, drawBorder_1.createTableBorderGetter)(columnWidths, config),
38 exports.drawTable = drawTable;
39 //# sourceMappingURL=drawTable.js.map