UNPKG

1.92 kBJavaScriptView Raw
1"use strict";
2// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3// See LICENSE in the project root for license information.
4Object.defineProperty(exports, "__esModule", { value: true });
5exports.DocTable = void 0;
6const tsdoc_1 = require("@microsoft/tsdoc");
7const DocTableRow_1 = require("./DocTableRow");
8/**
9 * Represents table, similar to an HTML `<table>` element.
10 */
11class DocTable extends tsdoc_1.DocNode {
12 constructor(parameters, rows) {
13 super(parameters);
14 this.header = new DocTableRow_1.DocTableRow({ configuration: this.configuration });
15 this._rows = [];
16 if (parameters) {
17 if (parameters.headerTitles) {
18 if (parameters.headerCells) {
19 throw new Error('IDocTableParameters.headerCells and IDocTableParameters.headerTitles' +
20 ' cannot both be specified');
21 }
22 for (const cellText of parameters.headerTitles) {
23 this.header.addPlainTextCell(cellText);
24 }
25 }
26 else if (parameters.headerCells) {
27 for (const cell of parameters.headerCells) {
28 this.header.addCell(cell);
29 }
30 }
31 }
32 if (rows) {
33 for (const row of rows) {
34 this.addRow(row);
35 }
36 }
37 }
38 /** @override */
39 get kind() {
40 return "Table" /* Table */;
41 }
42 get rows() {
43 return this._rows;
44 }
45 addRow(row) {
46 this._rows.push(row);
47 }
48 createAndAddRow() {
49 const row = new DocTableRow_1.DocTableRow({ configuration: this.configuration });
50 this.addRow(row);
51 return row;
52 }
53 /** @override */
54 onGetChildNodes() {
55 return [this.header, ...this._rows];
56 }
57}
58exports.DocTable = DocTable;
59//# sourceMappingURL=DocTable.js.map
\No newline at end of file