Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

drawTable.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 = utils_1.groupBySizes(rows, rowHeights).map((group) => {
  16. return group.map((row) => {
  17. return drawRow_1.drawRow(row, config);
  18. }).join('');
  19. });
  20. if (config.header) {
  21. // assume that topLeft/right border have width = 1
  22. const headerWidth = string_width_1.default(drawRow_1.drawRow(rows[0], config)) - 2 -
  23. config.header.paddingLeft - config.header.paddingRight;
  24. const header = drawHeader_1.drawHeader(headerWidth, config);
  25. contents.unshift(header);
  26. }
  27. return 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: drawBorder_1.createTableBorderGetter(columnWidths, config),
  36. });
  37. };
  38. exports.drawTable = drawTable;