table 6.1.0 → 6.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/alignString.d.ts +6 -0
- package/dist/alignString.js +51 -95
- package/dist/alignTableData.d.ts +3 -0
- package/dist/alignTableData.js +17 -31
- package/dist/calculateCellHeight.d.ts +2 -0
- package/dist/calculateCellHeight.js +14 -35
- package/dist/calculateCellWidthIndex.d.ts +6 -0
- package/dist/calculateCellWidthIndex.js +11 -22
- package/dist/calculateMaximumColumnWidthIndex.d.ts +6 -0
- package/dist/calculateMaximumColumnWidthIndex.js +18 -30
- package/dist/calculateRowHeightIndex.d.ts +6 -0
- package/dist/calculateRowHeightIndex.js +23 -39
- package/dist/createStream.d.ts +3 -0
- package/dist/createStream.js +65 -116
- package/dist/drawBorder.d.ts +25 -0
- package/dist/drawBorder.js +45 -106
- package/dist/drawHorizontalContent.d.ts +11 -0
- package/dist/drawHorizontalContent.js +17 -40
- package/dist/drawRow.d.ts +7 -0
- package/dist/drawRow.js +14 -39
- package/dist/drawTable.d.ts +3 -0
- package/dist/drawTable.js +33 -56
- package/dist/generated/validators.d.ts +13 -0
- package/dist/{validators.js → generated/validators.js} +309 -315
- package/dist/getBorderCharacters.d.ts +3 -0
- package/dist/getBorderCharacters.js +79 -115
- package/dist/{index.js.flow → index.d.ts} +2 -6
- package/dist/index.js +22 -30
- package/dist/makeConfig.d.ts +8 -0
- package/dist/makeConfig.js +42 -84
- package/dist/makeStreamConfig.d.ts +8 -0
- package/dist/makeStreamConfig.js +42 -90
- package/dist/mapDataUsingRowHeightIndex.d.ts +3 -0
- package/dist/mapDataUsingRowHeightIndex.js +23 -38
- package/dist/padTableData.d.ts +3 -0
- package/dist/padTableData.js +7 -20
- package/dist/stringifyTableData.d.ts +3 -0
- package/dist/stringifyTableData.js +5 -19
- package/dist/table.d.ts +3 -0
- package/dist/table.js +25 -119
- package/dist/truncateTableData.d.ts +6 -0
- package/dist/truncateTableData.js +13 -23
- package/dist/types/api.d.ts +100 -0
- package/dist/types/api.js +2 -0
- package/dist/types/internal.d.ts +1 -0
- package/dist/types/internal.js +2 -0
- package/dist/validateConfig.d.ts +3 -0
- package/dist/validateConfig.js +22 -38
- package/dist/validateTableData.d.ts +2 -0
- package/dist/validateTableData.js +23 -49
- package/dist/wrapCell.d.ts +9 -0
- package/dist/wrapCell.js +23 -38
- package/dist/wrapString.d.ts +10 -0
- package/dist/wrapString.js +14 -29
- package/dist/wrapWord.d.ts +2 -0
- package/dist/wrapWord.js +26 -44
- package/package.json +32 -24
- package/dist/alignString.js.flow +0 -97
- package/dist/alignTableData.js.flow +0 -21
- package/dist/calculateCellHeight.js.flow +0 -24
- package/dist/calculateCellWidthIndex.js.flow +0 -17
- package/dist/calculateMaximumColumnWidthIndex.js.flow +0 -27
- package/dist/calculateRowHeightIndex.js.flow +0 -36
- package/dist/createStream.js.flow +0 -125
- package/dist/drawBorder.js.flow +0 -89
- package/dist/drawHorizontalContent.js.flow +0 -31
- package/dist/drawRow.js.flow +0 -29
- package/dist/drawTable.js.flow +0 -64
- package/dist/getBorderCharacters.js.flow +0 -120
- package/dist/makeConfig.js.flow +0 -85
- package/dist/makeStreamConfig.js.flow +0 -92
- package/dist/mapDataUsingRowHeightIndex.js.flow +0 -34
- package/dist/padTableData.js.flow +0 -14
- package/dist/schemas/config.json +0 -26
- package/dist/schemas/shared.json +0 -98
- package/dist/schemas/streamConfig.json +0 -23
- package/dist/stringifyTableData.js.flow +0 -11
- package/dist/table.js.flow +0 -108
- package/dist/truncateTableData.js.flow +0 -17
- package/dist/validateConfig.js.flow +0 -27
- package/dist/validateTableData.js.flow +0 -44
- package/dist/wrapCell.js.flow +0 -35
- package/dist/wrapString.js.flow +0 -29
- package/dist/wrapWord.js.flow +0 -39
package/dist/createStream.js
CHANGED
|
@@ -1,124 +1,73 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _makeStreamConfig = _interopRequireDefault(require("./makeStreamConfig"));
|
|
17
|
-
|
|
18
|
-
var _mapDataUsingRowHeightIndex = _interopRequireDefault(require("./mapDataUsingRowHeightIndex"));
|
|
19
|
-
|
|
20
|
-
var _padTableData = _interopRequireDefault(require("./padTableData"));
|
|
21
|
-
|
|
22
|
-
var _stringifyTableData = _interopRequireDefault(require("./stringifyTableData"));
|
|
23
|
-
|
|
24
|
-
var _truncateTableData = _interopRequireDefault(require("./truncateTableData"));
|
|
25
|
-
|
|
26
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param {Array} data
|
|
30
|
-
* @param {streamConfig} config
|
|
31
|
-
* @returns {Array}
|
|
32
|
-
*/
|
|
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
|
+
const alignTableData_1 = __importDefault(require("./alignTableData"));
|
|
7
|
+
const calculateRowHeightIndex_1 = __importDefault(require("./calculateRowHeightIndex"));
|
|
8
|
+
const drawBorder_1 = require("./drawBorder");
|
|
9
|
+
const drawRow_1 = __importDefault(require("./drawRow"));
|
|
10
|
+
const makeStreamConfig_1 = __importDefault(require("./makeStreamConfig"));
|
|
11
|
+
const mapDataUsingRowHeightIndex_1 = __importDefault(require("./mapDataUsingRowHeightIndex"));
|
|
12
|
+
const padTableData_1 = __importDefault(require("./padTableData"));
|
|
13
|
+
const stringifyTableData_1 = __importDefault(require("./stringifyTableData"));
|
|
14
|
+
const truncateTableData_1 = __importDefault(require("./truncateTableData"));
|
|
33
15
|
const prepareData = (data, config) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return rows;
|
|
16
|
+
let rows = stringifyTableData_1.default(data);
|
|
17
|
+
rows = truncateTableData_1.default(rows, config);
|
|
18
|
+
const rowHeightIndex = calculateRowHeightIndex_1.default(rows, config);
|
|
19
|
+
rows = mapDataUsingRowHeightIndex_1.default(rows, rowHeightIndex, config);
|
|
20
|
+
rows = alignTableData_1.default(rows, config);
|
|
21
|
+
rows = padTableData_1.default(rows, config);
|
|
22
|
+
return rows;
|
|
42
23
|
};
|
|
43
|
-
/**
|
|
44
|
-
* @param {string[]} row
|
|
45
|
-
* @param {number[]} columnWidthIndex
|
|
46
|
-
* @param {streamConfig} config
|
|
47
|
-
* @returns {undefined}
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
24
|
const create = (row, columnWidthIndex, config) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
25
|
+
const rows = prepareData([row], config);
|
|
26
|
+
const body = rows.map((literalRow) => {
|
|
27
|
+
return drawRow_1.default(literalRow, config);
|
|
28
|
+
}).join('');
|
|
29
|
+
let output;
|
|
30
|
+
output = '';
|
|
31
|
+
output += drawBorder_1.drawBorderTop(columnWidthIndex, config);
|
|
32
|
+
output += body;
|
|
33
|
+
output += drawBorder_1.drawBorderBottom(columnWidthIndex, config);
|
|
34
|
+
output = output.trimEnd();
|
|
35
|
+
process.stdout.write(output);
|
|
63
36
|
};
|
|
64
|
-
/**
|
|
65
|
-
* @param {string[]} row
|
|
66
|
-
* @param {number[]} columnWidthIndex
|
|
67
|
-
* @param {streamConfig} config
|
|
68
|
-
* @returns {undefined}
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
37
|
const append = (row, columnWidthIndex, config) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
output = '\r\u001B[K';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
output += (0, _drawBorder.drawBorderJoin)(columnWidthIndex, config);
|
|
85
|
-
output += body;
|
|
86
|
-
output += bottom;
|
|
87
|
-
output = output.trimEnd();
|
|
88
|
-
process.stdout.write(output);
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* @param {object} userConfig
|
|
92
|
-
* @returns {object}
|
|
93
|
-
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const createStream = (userConfig = {}) => {
|
|
97
|
-
const config = (0, _makeStreamConfig.default)(userConfig);
|
|
98
|
-
const columnWidthIndex = Object.values(config.columns).map(column => {
|
|
99
|
-
return column.width + column.paddingLeft + column.paddingRight;
|
|
100
|
-
});
|
|
101
|
-
let empty;
|
|
102
|
-
empty = true;
|
|
103
|
-
return {
|
|
104
|
-
/**
|
|
105
|
-
* @param {string[]} row
|
|
106
|
-
* @returns {undefined}
|
|
107
|
-
*/
|
|
108
|
-
write: row => {
|
|
109
|
-
if (row.length !== config.columnCount) {
|
|
110
|
-
throw new Error('Row cell count does not match the config.columnCount.');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (empty) {
|
|
114
|
-
empty = false;
|
|
115
|
-
return create(row, columnWidthIndex, config);
|
|
116
|
-
} else {
|
|
117
|
-
return append(row, columnWidthIndex, config);
|
|
118
|
-
}
|
|
38
|
+
const rows = prepareData([row], config);
|
|
39
|
+
const body = rows.map((literalRow) => {
|
|
40
|
+
return drawRow_1.default(literalRow, config);
|
|
41
|
+
}).join('');
|
|
42
|
+
let output = '';
|
|
43
|
+
const bottom = drawBorder_1.drawBorderBottom(columnWidthIndex, config);
|
|
44
|
+
if (bottom !== '\n') {
|
|
45
|
+
output = '\r\u001B[K';
|
|
119
46
|
}
|
|
120
|
-
|
|
47
|
+
output += drawBorder_1.drawBorderJoin(columnWidthIndex, config);
|
|
48
|
+
output += body;
|
|
49
|
+
output += bottom;
|
|
50
|
+
output = output.trimEnd();
|
|
51
|
+
process.stdout.write(output);
|
|
52
|
+
};
|
|
53
|
+
exports.default = (userConfig) => {
|
|
54
|
+
const config = makeStreamConfig_1.default(userConfig);
|
|
55
|
+
const columnWidthIndex = Object.values(config.columns).map((column) => {
|
|
56
|
+
return column.width + column.paddingLeft + column.paddingRight;
|
|
57
|
+
});
|
|
58
|
+
let empty = true;
|
|
59
|
+
return {
|
|
60
|
+
write: (row) => {
|
|
61
|
+
if (row.length !== config.columnCount) {
|
|
62
|
+
throw new Error('Row cell count does not match the config.columnCount.');
|
|
63
|
+
}
|
|
64
|
+
if (empty) {
|
|
65
|
+
empty = false;
|
|
66
|
+
create(row, columnWidthIndex, config);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
append(row, columnWidthIndex, config);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
};
|
|
121
73
|
};
|
|
122
|
-
|
|
123
|
-
var _default = createStream;
|
|
124
|
-
exports.default = _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DrawVerticalLine } from './types/api';
|
|
2
|
+
import type { BottomBorderConfig, JoinBorderConfig, TopBorderConfig } from './types/internal';
|
|
3
|
+
declare type Separator = {
|
|
4
|
+
readonly left: string;
|
|
5
|
+
readonly right: string;
|
|
6
|
+
readonly body: string;
|
|
7
|
+
readonly join: string;
|
|
8
|
+
};
|
|
9
|
+
declare const drawBorder: (columnSizeIndex: number[], config: {
|
|
10
|
+
separator: Separator;
|
|
11
|
+
drawVerticalLine: DrawVerticalLine;
|
|
12
|
+
}) => string;
|
|
13
|
+
declare const drawBorderTop: (columnSizeIndex: number[], config: {
|
|
14
|
+
border: TopBorderConfig;
|
|
15
|
+
drawVerticalLine: DrawVerticalLine;
|
|
16
|
+
}) => string;
|
|
17
|
+
declare const drawBorderJoin: (columnSizeIndex: number[], config: {
|
|
18
|
+
border: JoinBorderConfig;
|
|
19
|
+
drawVerticalLine: DrawVerticalLine;
|
|
20
|
+
}) => string;
|
|
21
|
+
declare const drawBorderBottom: (columnSizeIndex: number[], config: {
|
|
22
|
+
border: BottomBorderConfig;
|
|
23
|
+
drawVerticalLine: DrawVerticalLine;
|
|
24
|
+
}) => string;
|
|
25
|
+
export { drawBorder, drawBorderBottom, drawBorderJoin, drawBorderTop, };
|
package/dist/drawBorder.js
CHANGED
|
@@ -1,115 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
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
6
|
exports.drawBorderTop = exports.drawBorderJoin = exports.drawBorderBottom = exports.drawBorder = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* @typedef drawBorder~border
|
|
14
|
-
* @property {string} left
|
|
15
|
-
* @property {string} right
|
|
16
|
-
* @property {string} body
|
|
17
|
-
* @property {string} join
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @param {number[]} columnSizeIndex
|
|
22
|
-
* @param {object} config
|
|
23
|
-
* @param {drawBorder~border} config.border
|
|
24
|
-
* @param {Function} config.drawVerticalLine
|
|
25
|
-
* @returns {string}
|
|
26
|
-
*/
|
|
27
|
-
const drawBorder = (columnSizeIndex, {
|
|
28
|
-
border,
|
|
29
|
-
drawVerticalLine
|
|
30
|
-
}) => {
|
|
31
|
-
const columns = columnSizeIndex.map(size => {
|
|
32
|
-
return border.body.repeat(size);
|
|
33
|
-
});
|
|
34
|
-
return (0, _drawHorizontalContent.default)(columns, {
|
|
35
|
-
drawVerticalLine,
|
|
36
|
-
separator: border
|
|
37
|
-
});
|
|
7
|
+
const drawHorizontalContent_1 = __importDefault(require("./drawHorizontalContent"));
|
|
8
|
+
const drawBorder = (columnSizeIndex, config) => {
|
|
9
|
+
const columns = columnSizeIndex.map((size) => {
|
|
10
|
+
return config.separator.body.repeat(size);
|
|
11
|
+
});
|
|
12
|
+
return drawHorizontalContent_1.default(columns, config);
|
|
38
13
|
};
|
|
39
|
-
/**
|
|
40
|
-
* @param {number[]} columnSizeIndex
|
|
41
|
-
* @param {table~config} config
|
|
42
|
-
* @returns {string}
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
14
|
exports.drawBorder = drawBorder;
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (result === '\n') {
|
|
63
|
-
return '';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return result;
|
|
15
|
+
const drawBorderTop = (columnSizeIndex, config) => {
|
|
16
|
+
const result = drawBorder(columnSizeIndex, {
|
|
17
|
+
...config,
|
|
18
|
+
separator: {
|
|
19
|
+
body: config.border.topBody,
|
|
20
|
+
join: config.border.topJoin,
|
|
21
|
+
left: config.border.topLeft,
|
|
22
|
+
right: config.border.topRight,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
if (result === '\n') {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
67
29
|
};
|
|
68
|
-
/**
|
|
69
|
-
* @param {number[]} columnSizeIndex
|
|
70
|
-
* @param {table~config} config
|
|
71
|
-
* @returns {string}
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
30
|
exports.drawBorderTop = drawBorderTop;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
right: border.joinRight
|
|
87
|
-
},
|
|
88
|
-
drawVerticalLine
|
|
89
|
-
});
|
|
31
|
+
const drawBorderJoin = (columnSizeIndex, config) => {
|
|
32
|
+
return drawBorder(columnSizeIndex, {
|
|
33
|
+
...config,
|
|
34
|
+
separator: {
|
|
35
|
+
body: config.border.joinBody,
|
|
36
|
+
join: config.border.joinJoin,
|
|
37
|
+
left: config.border.joinLeft,
|
|
38
|
+
right: config.border.joinRight,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
90
41
|
};
|
|
91
|
-
/**
|
|
92
|
-
* @param {number[]} columnSizeIndex
|
|
93
|
-
* @param {table~config} config
|
|
94
|
-
* @returns {string}
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
42
|
exports.drawBorderJoin = drawBorderJoin;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
right: border.bottomRight
|
|
110
|
-
},
|
|
111
|
-
drawVerticalLine
|
|
112
|
-
});
|
|
43
|
+
const drawBorderBottom = (columnSizeIndex, config) => {
|
|
44
|
+
return drawBorder(columnSizeIndex, {
|
|
45
|
+
...config,
|
|
46
|
+
separator: {
|
|
47
|
+
body: config.border.bottomBody,
|
|
48
|
+
join: config.border.bottomJoin,
|
|
49
|
+
left: config.border.bottomLeft,
|
|
50
|
+
right: config.border.bottomRight,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
113
53
|
};
|
|
114
|
-
|
|
115
|
-
exports.drawBorderBottom = drawBorderBottom;
|
|
54
|
+
exports.drawBorderBottom = drawBorderBottom;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DrawVerticalLine } from './types/api';
|
|
2
|
+
declare type Separator = {
|
|
3
|
+
readonly left: string;
|
|
4
|
+
readonly right: string;
|
|
5
|
+
readonly join: string;
|
|
6
|
+
};
|
|
7
|
+
export default function drawHorizontalContent(contents: string[], config: {
|
|
8
|
+
separator: Separator;
|
|
9
|
+
drawVerticalLine: DrawVerticalLine;
|
|
10
|
+
}): string;
|
|
11
|
+
export {};
|
|
@@ -1,41 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* @param {Function} config.drawVerticalLine
|
|
20
|
-
* @returns {string}
|
|
21
|
-
*/
|
|
22
|
-
const drawHorizontalContent = (columns, {
|
|
23
|
-
separator,
|
|
24
|
-
drawVerticalLine
|
|
25
|
-
}) => {
|
|
26
|
-
const columnCount = columns.length;
|
|
27
|
-
const result = [];
|
|
28
|
-
result.push(drawVerticalLine(0, columnCount) ? separator.left : '');
|
|
29
|
-
columns.forEach((column, index) => {
|
|
30
|
-
result.push(column);
|
|
31
|
-
|
|
32
|
-
if (index + 1 < columnCount) {
|
|
33
|
-
result.push(drawVerticalLine(index + 1, columnCount) ? separator.join : '');
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
result.push(drawVerticalLine(columnCount, columnCount) ? separator.right : '');
|
|
37
|
-
return result.join('') + '\n';
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
var _default = drawHorizontalContent;
|
|
41
|
-
exports.default = _default;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function drawHorizontalContent(contents, config) {
|
|
4
|
+
const { separator, drawVerticalLine } = config;
|
|
5
|
+
const contentSize = contents.length;
|
|
6
|
+
const result = [];
|
|
7
|
+
result.push(drawVerticalLine(0, contentSize) ? separator.left : '');
|
|
8
|
+
contents.forEach((content, index) => {
|
|
9
|
+
result.push(content);
|
|
10
|
+
// Only append the join separator if it is not the last content
|
|
11
|
+
if (index + 1 < contentSize) {
|
|
12
|
+
result.push(drawVerticalLine(index + 1, contentSize) ? separator.join : '');
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
result.push(drawVerticalLine(contentSize, contentSize) ? separator.right : '');
|
|
16
|
+
return result.join('') + '\n';
|
|
17
|
+
}
|
|
18
|
+
exports.default = drawHorizontalContent;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DrawVerticalLine } from './types/api';
|
|
2
|
+
import type { BodyBorderConfig, Row } from './types/internal';
|
|
3
|
+
declare const _default: (row: Row, config: {
|
|
4
|
+
border: BodyBorderConfig;
|
|
5
|
+
drawVerticalLine: DrawVerticalLine;
|
|
6
|
+
}) => string;
|
|
7
|
+
export default _default;
|
package/dist/drawRow.js
CHANGED
|
@@ -1,41 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* @property {string} bodyJoin
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @param {string[]} columns
|
|
21
|
-
* @param {object} config
|
|
22
|
-
* @param {border} config.border
|
|
23
|
-
* @param {Function} config.drawVerticalLine
|
|
24
|
-
* @returns {string}
|
|
25
|
-
*/
|
|
26
|
-
const drawRow = (columns, {
|
|
27
|
-
border,
|
|
28
|
-
drawVerticalLine
|
|
29
|
-
}) => {
|
|
30
|
-
return (0, _drawHorizontalContent.default)(columns, {
|
|
31
|
-
drawVerticalLine,
|
|
32
|
-
separator: {
|
|
33
|
-
join: border.bodyJoin,
|
|
34
|
-
left: border.bodyLeft,
|
|
35
|
-
right: border.bodyRight
|
|
36
|
-
}
|
|
37
|
-
});
|
|
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
|
+
const drawHorizontalContent_1 = __importDefault(require("./drawHorizontalContent"));
|
|
7
|
+
exports.default = (row, config) => {
|
|
8
|
+
return drawHorizontalContent_1.default(row, {
|
|
9
|
+
...config,
|
|
10
|
+
separator: {
|
|
11
|
+
join: config.border.bodyJoin,
|
|
12
|
+
left: config.border.bodyLeft,
|
|
13
|
+
right: config.border.bodyRight,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
38
16
|
};
|
|
39
|
-
|
|
40
|
-
var _default = drawRow;
|
|
41
|
-
exports.default = _default;
|
package/dist/drawTable.js
CHANGED
|
@@ -1,60 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* @param {table~config} config
|
|
19
|
-
* @returns {string}
|
|
20
|
-
*/
|
|
21
|
-
const drawTable = (rows, columnSizeIndex, rowSpanIndex, config) => {
|
|
22
|
-
const {
|
|
23
|
-
drawHorizontalLine,
|
|
24
|
-
singleLine
|
|
25
|
-
} = config;
|
|
26
|
-
let output;
|
|
27
|
-
let realRowIndex;
|
|
28
|
-
let rowHeight;
|
|
29
|
-
const rowCount = rows.length;
|
|
30
|
-
realRowIndex = 0;
|
|
31
|
-
output = '';
|
|
32
|
-
|
|
33
|
-
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
|
34
|
-
output += (0, _drawBorder.drawBorderTop)(columnSizeIndex, config);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
rows.forEach((row, index0) => {
|
|
38
|
-
output += (0, _drawRow.default)(row, config);
|
|
39
|
-
|
|
40
|
-
if (!rowHeight) {
|
|
41
|
-
rowHeight = rowSpanIndex[realRowIndex];
|
|
42
|
-
realRowIndex++;
|
|
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
|
+
const drawBorder_1 = require("./drawBorder");
|
|
7
|
+
const drawRow_1 = __importDefault(require("./drawRow"));
|
|
8
|
+
exports.default = (rows, columnSizeIndex, rowSpanIndex, config) => {
|
|
9
|
+
const { drawHorizontalLine, singleLine, } = config;
|
|
10
|
+
let output;
|
|
11
|
+
let realRowIndex;
|
|
12
|
+
let rowHeight;
|
|
13
|
+
const rowCount = rows.length;
|
|
14
|
+
realRowIndex = 0;
|
|
15
|
+
output = '';
|
|
16
|
+
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
|
17
|
+
output += drawBorder_1.drawBorderTop(columnSizeIndex, config);
|
|
43
18
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
19
|
+
rows.forEach((row, index0) => {
|
|
20
|
+
output += drawRow_1.default(row, config);
|
|
21
|
+
if (!rowHeight) {
|
|
22
|
+
rowHeight = rowSpanIndex[realRowIndex];
|
|
23
|
+
realRowIndex++;
|
|
24
|
+
}
|
|
25
|
+
rowHeight--;
|
|
26
|
+
if (!singleLine &&
|
|
27
|
+
rowHeight === 0 &&
|
|
28
|
+
index0 !== rowCount - 1 &&
|
|
29
|
+
drawHorizontalLine(realRowIndex, rowCount)) {
|
|
30
|
+
output += drawBorder_1.drawBorderJoin(columnSizeIndex, config);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
|
34
|
+
output += drawBorder_1.drawBorderBottom(columnSizeIndex, config);
|
|
49
35
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (drawHorizontalLine(realRowIndex, rowCount)) {
|
|
53
|
-
output += (0, _drawBorder.drawBorderBottom)(columnSizeIndex, config);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return output;
|
|
36
|
+
return output;
|
|
57
37
|
};
|
|
58
|
-
|
|
59
|
-
var _default = drawTable;
|
|
60
|
-
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare function validate43(data: any, { instancePath, parentData, parentDataProperty, rootData }?: {
|
|
2
|
+
instancePath?: string | undefined;
|
|
3
|
+
parentData: any;
|
|
4
|
+
parentDataProperty: any;
|
|
5
|
+
rootData?: any;
|
|
6
|
+
}): boolean;
|
|
7
|
+
declare function validate69(data: any, { instancePath, parentData, parentDataProperty, rootData }?: {
|
|
8
|
+
instancePath?: string | undefined;
|
|
9
|
+
parentData: any;
|
|
10
|
+
parentDataProperty: any;
|
|
11
|
+
rootData?: any;
|
|
12
|
+
}): boolean;
|
|
13
|
+
export { validate43 as _config_json, validate69 as _streamConfig_json };
|