table 6.0.6 → 6.1.0
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 +52 -1
- package/dist/alignString.js +6 -7
- package/dist/alignString.js.flow +5 -4
- package/dist/alignTableData.js +1 -2
- package/dist/calculateCellHeight.js +3 -4
- package/dist/calculateCellHeight.js.flow +2 -2
- package/dist/calculateCellWidthIndex.js +1 -2
- package/dist/calculateMaximumColumnWidthIndex.js +1 -2
- package/dist/calculateRowHeightIndex.js +6 -9
- package/dist/calculateRowHeightIndex.js.flow +5 -4
- package/dist/createStream.js +13 -16
- package/dist/createStream.js.flow +12 -13
- package/dist/drawBorder.js +58 -53
- package/dist/drawBorder.js.flow +43 -55
- package/dist/drawHorizontalContent.js +41 -0
- package/dist/drawHorizontalContent.js.flow +31 -0
- package/dist/drawRow.js +21 -6
- package/dist/drawRow.js.flow +18 -4
- package/dist/drawTable.js +12 -11
- package/dist/drawTable.js.flow +24 -13
- package/dist/getBorderCharacters.js +1 -2
- package/dist/index.js +1 -2
- package/dist/makeConfig.js +19 -13
- package/dist/makeConfig.js.flow +16 -7
- package/dist/makeStreamConfig.js +17 -11
- package/dist/makeStreamConfig.js.flow +14 -5
- package/dist/mapDataUsingRowHeightIndex.js +4 -7
- package/dist/mapDataUsingRowHeightIndex.js.flow +3 -3
- package/dist/padTableData.js +1 -2
- package/dist/schemas/config.json +6 -0
- package/dist/schemas/streamConfig.json +3 -0
- package/dist/stringifyTableData.js +1 -2
- package/dist/table.js +14 -3
- package/dist/table.js.flow +13 -1
- package/dist/truncateTableData.js +3 -4
- package/dist/truncateTableData.js.flow +2 -2
- package/dist/validateConfig.js +1 -4
- package/dist/validateConfig.js.flow +0 -1
- package/dist/validateTableData.js +1 -2
- package/dist/validators.js +247 -186
- package/dist/wrapCell.js +1 -2
- package/dist/wrapString.js +1 -2
- package/dist/wrapWord.js +1 -2
- package/package.json +14 -8
- package/dist/alignString.js.map +0 -1
- package/dist/alignTableData.js.map +0 -1
- package/dist/calculateCellHeight.js.map +0 -1
- package/dist/calculateCellWidthIndex.js.map +0 -1
- package/dist/calculateMaximumColumnWidthIndex.js.map +0 -1
- package/dist/calculateRowHeightIndex.js.map +0 -1
- package/dist/createStream.js.map +0 -1
- package/dist/drawBorder.js.map +0 -1
- package/dist/drawRow.js.map +0 -1
- package/dist/drawTable.js.map +0 -1
- package/dist/getBorderCharacters.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/makeConfig.js.map +0 -1
- package/dist/makeStreamConfig.js.map +0 -1
- package/dist/mapDataUsingRowHeightIndex.js.map +0 -1
- package/dist/padTableData.js.map +0 -1
- package/dist/stringifyTableData.js.map +0 -1
- package/dist/table.js.map +0 -1
- package/dist/truncateTableData.js.map +0 -1
- package/dist/validateConfig.js.map +0 -1
- package/dist/validateTableData.js.map +0 -1
- package/dist/wrapCell.js.map +0 -1
- package/dist/wrapString.js.map +0 -1
- package/dist/wrapWord.js.map +0 -1
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
var _times2 = _interopRequireDefault(require("lodash/times"));
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash.flatten"));
|
|
11
9
|
|
|
12
10
|
var _wrapCell = _interopRequireDefault(require("./wrapCell"));
|
|
13
11
|
|
|
@@ -22,7 +20,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
22
20
|
const mapDataUsingRowHeightIndex = (unmappedRows, rowHeightIndex, config) => {
|
|
23
21
|
const tableWidth = unmappedRows[0].length;
|
|
24
22
|
const mappedRows = unmappedRows.map((cells, index0) => {
|
|
25
|
-
const rowHeight = (
|
|
23
|
+
const rowHeight = Array.from(new Array(rowHeightIndex[index0]), () => {
|
|
26
24
|
return new Array(tableWidth).fill('');
|
|
27
25
|
}); // rowHeight
|
|
28
26
|
// [{row index within rowSaw; index2}]
|
|
@@ -36,9 +34,8 @@ const mapDataUsingRowHeightIndex = (unmappedRows, rowHeightIndex, config) => {
|
|
|
36
34
|
});
|
|
37
35
|
return rowHeight;
|
|
38
36
|
});
|
|
39
|
-
return (0,
|
|
37
|
+
return (0, _lodash.default)(mappedRows);
|
|
40
38
|
};
|
|
41
39
|
|
|
42
40
|
var _default = mapDataUsingRowHeightIndex;
|
|
43
|
-
exports.default = _default;
|
|
44
|
-
//# sourceMappingURL=mapDataUsingRowHeightIndex.js.map
|
|
41
|
+
exports.default = _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import flatten from 'lodash.flatten';
|
|
2
2
|
import wrapCell from './wrapCell';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -11,7 +11,7 @@ export default (unmappedRows, rowHeightIndex, config) => {
|
|
|
11
11
|
const tableWidth = unmappedRows[0].length;
|
|
12
12
|
|
|
13
13
|
const mappedRows = unmappedRows.map((cells, index0) => {
|
|
14
|
-
const rowHeight =
|
|
14
|
+
const rowHeight = Array.from(new Array(rowHeightIndex[index0]), () => {
|
|
15
15
|
return new Array(tableWidth).fill('');
|
|
16
16
|
});
|
|
17
17
|
|
|
@@ -30,5 +30,5 @@ export default (unmappedRows, rowHeightIndex, config) => {
|
|
|
30
30
|
return rowHeight;
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
return
|
|
33
|
+
return flatten(mappedRows);
|
|
34
34
|
};
|
package/dist/padTableData.js
CHANGED
package/dist/schemas/config.json
CHANGED
|
@@ -12,8 +12,14 @@
|
|
|
12
12
|
"columnDefault": {
|
|
13
13
|
"$ref": "shared.json#/definitions/column"
|
|
14
14
|
},
|
|
15
|
+
"drawVerticalLine": {
|
|
16
|
+
"typeof": "function"
|
|
17
|
+
},
|
|
15
18
|
"drawHorizontalLine": {
|
|
16
19
|
"typeof": "function"
|
|
20
|
+
},
|
|
21
|
+
"singleLine": {
|
|
22
|
+
"typeof": "boolean"
|
|
17
23
|
}
|
|
18
24
|
},
|
|
19
25
|
"additionalProperties": false
|
package/dist/table.js
CHANGED
|
@@ -64,6 +64,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
64
64
|
* @property {string} joinJoin
|
|
65
65
|
*/
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Used to tell whether to draw a vertical line.
|
|
69
|
+
* This callback is called for each non-content line of the table.
|
|
70
|
+
* The default behavior is to always return true.
|
|
71
|
+
*
|
|
72
|
+
* @typedef {Function} drawVerticalLine
|
|
73
|
+
* @param {number} index
|
|
74
|
+
* @param {number} size
|
|
75
|
+
* @returns {boolean}
|
|
76
|
+
*/
|
|
77
|
+
|
|
67
78
|
/**
|
|
68
79
|
* Used to tell whether to draw a horizontal line.
|
|
69
80
|
* This callback is called for each non-content line of the table.
|
|
@@ -80,6 +91,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
80
91
|
* @property {table~border} border
|
|
81
92
|
* @property {table~columns[]} columns Column specific configuration.
|
|
82
93
|
* @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values.
|
|
94
|
+
* @property {table~drawVerticalLine} drawVerticalLine
|
|
83
95
|
* @property {table~drawHorizontalLine} drawHorizontalLine
|
|
84
96
|
* @property {table~singleLine} singleLine Horizontal lines inside the table are not drawn.
|
|
85
97
|
*/
|
|
@@ -102,9 +114,8 @@ const table = (data, userConfig = {}) => {
|
|
|
102
114
|
rows = (0, _alignTableData.default)(rows, config);
|
|
103
115
|
rows = (0, _padTableData.default)(rows, config);
|
|
104
116
|
const cellWidthIndex = (0, _calculateCellWidthIndex.default)(rows[0]);
|
|
105
|
-
return (0, _drawTable.default)(rows,
|
|
117
|
+
return (0, _drawTable.default)(rows, cellWidthIndex, rowHeightIndex, config);
|
|
106
118
|
};
|
|
107
119
|
|
|
108
120
|
var _default = table;
|
|
109
|
-
exports.default = _default;
|
|
110
|
-
//# sourceMappingURL=table.js.map
|
|
121
|
+
exports.default = _default;
|
package/dist/table.js.flow
CHANGED
|
@@ -46,6 +46,17 @@ import validateTableData from './validateTableData';
|
|
|
46
46
|
* @property {string} joinJoin
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Used to tell whether to draw a vertical line.
|
|
51
|
+
* This callback is called for each non-content line of the table.
|
|
52
|
+
* The default behavior is to always return true.
|
|
53
|
+
*
|
|
54
|
+
* @typedef {Function} drawVerticalLine
|
|
55
|
+
* @param {number} index
|
|
56
|
+
* @param {number} size
|
|
57
|
+
* @returns {boolean}
|
|
58
|
+
*/
|
|
59
|
+
|
|
49
60
|
/**
|
|
50
61
|
* Used to tell whether to draw a horizontal line.
|
|
51
62
|
* This callback is called for each non-content line of the table.
|
|
@@ -62,6 +73,7 @@ import validateTableData from './validateTableData';
|
|
|
62
73
|
* @property {table~border} border
|
|
63
74
|
* @property {table~columns[]} columns Column specific configuration.
|
|
64
75
|
* @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values.
|
|
76
|
+
* @property {table~drawVerticalLine} drawVerticalLine
|
|
65
77
|
* @property {table~drawHorizontalLine} drawHorizontalLine
|
|
66
78
|
* @property {table~singleLine} singleLine Horizontal lines inside the table are not drawn.
|
|
67
79
|
*/
|
|
@@ -92,5 +104,5 @@ export default (data, userConfig = {}) => {
|
|
|
92
104
|
|
|
93
105
|
const cellWidthIndex = calculateCellWidthIndex(rows[0]);
|
|
94
106
|
|
|
95
|
-
return drawTable(rows,
|
|
107
|
+
return drawTable(rows, cellWidthIndex, rowHeightIndex, config);
|
|
96
108
|
};
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash.truncate"));
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
@@ -18,7 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
18
|
const truncateTableData = (rows, config) => {
|
|
19
19
|
return rows.map(cells => {
|
|
20
20
|
return cells.map((content, index) => {
|
|
21
|
-
return (0,
|
|
21
|
+
return (0, _lodash.default)(content, {
|
|
22
22
|
length: config.columns[index].truncate
|
|
23
23
|
});
|
|
24
24
|
});
|
|
@@ -26,5 +26,4 @@ const truncateTableData = (rows, config) => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
var _default = truncateTableData;
|
|
29
|
-
exports.default = _default;
|
|
30
|
-
//# sourceMappingURL=truncateTableData.js.map
|
|
29
|
+
exports.default = _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import truncate from 'lodash.truncate';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @todo Make it work with ASCII content.
|
|
@@ -9,7 +9,7 @@ import _ from 'lodash';
|
|
|
9
9
|
export default (rows, config) => {
|
|
10
10
|
return rows.map((cells) => {
|
|
11
11
|
return cells.map((content, index) => {
|
|
12
|
-
return
|
|
12
|
+
return truncate(content, {
|
|
13
13
|
length: config.columns[index].truncate,
|
|
14
14
|
});
|
|
15
15
|
});
|
package/dist/validateConfig.js
CHANGED
|
@@ -9,8 +9,6 @@ var _validators = _interopRequireDefault(require("../dist/validators"));
|
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
|
-
// eslint-disable-next-line import/default
|
|
13
|
-
|
|
14
12
|
/**
|
|
15
13
|
* @param {string} schemaId
|
|
16
14
|
* @param {formatData~config} config
|
|
@@ -39,5 +37,4 @@ const validateConfig = (schemaId, config = {}) => {
|
|
|
39
37
|
};
|
|
40
38
|
|
|
41
39
|
var _default = validateConfig;
|
|
42
|
-
exports.default = _default;
|
|
43
|
-
//# sourceMappingURL=validateConfig.js.map
|
|
40
|
+
exports.default = _default;
|