massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / table / dist / src / drawTable.js
1 "use strict";
2 var __importDefault = (this && this.__importDefault) || function (mod) {
3     return (mod && mod.__esModule) ? mod : { "default": mod };
4 };
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);
18         }).join('');
19     });
20     if (config.header) {
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);
26     }
27     return (0, drawContent_1.drawContent)(contents, {
28         drawSeparator: (index, size) => {
29             // Top/bottom border
30             if (index === 0 || index === size) {
31                 return drawHorizontalLine(index, size);
32             }
33             return !singleLine && drawHorizontalLine(index, size);
34         },
35         separatorGetter: (0, drawBorder_1.createTableBorderGetter)(columnWidths, config),
36     });
37 };
38 exports.drawTable = drawTable;
39 //# sourceMappingURL=drawTable.js.map