colored-table 0.1.0-alpha.0 → 0.2.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.
Files changed (54) hide show
  1. package/LICENSE +3 -3
  2. package/README.md +3 -11
  3. package/cjs/build/buildBody.js +85 -0
  4. package/cjs/build/buildHeader.js +63 -0
  5. package/cjs/build/computerMaxLen.js +48 -0
  6. package/cjs/build/createPen.js +25 -0
  7. package/cjs/build/index.js +56 -0
  8. package/cjs/core.js +51 -0
  9. package/cjs/ele/rowEle.js +12 -0
  10. package/cjs/ele/tableEle.js +13 -0
  11. package/cjs/global.js +53 -0
  12. package/cjs/index.js +20 -0
  13. package/cjs/lines.js +19 -0
  14. package/cjs/parse/parse.js +44 -0
  15. package/cjs/parse/parseCell.js +27 -0
  16. package/cjs/parse/parseRow.js +35 -0
  17. package/cjs/proto/createHeaderProto.js +33 -0
  18. package/cjs/proto/setPro.js +74 -0
  19. package/es/build/buildBody.js +83 -0
  20. package/es/build/buildHeader.js +61 -0
  21. package/es/build/computerMaxLen.js +46 -0
  22. package/es/build/createPen.js +23 -0
  23. package/es/build/index.js +54 -0
  24. package/es/core.js +49 -0
  25. package/es/ele/rowEle.js +10 -0
  26. package/es/ele/tableEle.js +11 -0
  27. package/es/global.js +49 -0
  28. package/es/index.js +16 -0
  29. package/es/lines.js +17 -0
  30. package/es/parse/parse.js +42 -0
  31. package/es/parse/parseCell.js +25 -0
  32. package/es/parse/parseRow.js +32 -0
  33. package/es/proto/createHeaderProto.js +31 -0
  34. package/es/proto/setPro.js +72 -0
  35. package/{index.d.ts → es/src/index.d.ts} +3 -3
  36. package/package.json +37 -34
  37. package/index.cjs +0 -1
  38. package/index.mjs +0 -1
  39. /package/{src → es/src}/build/buildBody.d.ts +0 -0
  40. /package/{src → es/src}/build/buildHeader.d.ts +0 -0
  41. /package/{src → es/src}/build/computerMaxLen.d.ts +0 -0
  42. /package/{src → es/src}/build/createPen.d.ts +0 -0
  43. /package/{src → es/src}/build/index.d.ts +0 -0
  44. /package/{src → es/src}/core.d.ts +0 -0
  45. /package/{src → es/src}/ele/rowEle.d.ts +0 -0
  46. /package/{src → es/src}/ele/tableEle.d.ts +0 -0
  47. /package/{src → es/src}/global.d.ts +0 -0
  48. /package/{src → es/src}/lines.d.ts +0 -0
  49. /package/{src → es/src}/parse/parse.d.ts +0 -0
  50. /package/{src → es/src}/parse/parseCell.d.ts +0 -0
  51. /package/{src → es/src}/parse/parseRow.d.ts +0 -0
  52. /package/{src → es/src}/proto/createHeaderProto.d.ts +0 -0
  53. /package/{src → es/src}/proto/setPro.d.ts +0 -0
  54. /package/{src → es/src}/types.d.ts +0 -0
@@ -0,0 +1,74 @@
1
+ 'use strict';
2
+
3
+ var aTypeOfJs = require('a-type-of-js');
4
+
5
+ /** 配置原型上的属性 */
6
+ function setPro(targetObj, options) {
7
+ if (options.align) {
8
+ targetObj.align = options.align;
9
+ }
10
+ if (options.bgColor) {
11
+ targetObj.bgColor = options.bgColor;
12
+ }
13
+ if (options.color) {
14
+ targetObj.color = options.color;
15
+ }
16
+ if (options.italic) {
17
+ targetObj.italic = options.italic;
18
+ }
19
+ if (options.underline) {
20
+ targetObj.underline = options.underline;
21
+ }
22
+ if (options.border) {
23
+ if (aTypeOfJs.isType(options.border, e => aTypeOfJs.isString(e))) {
24
+ const style = options.border;
25
+ targetObj.border = {
26
+ left: {
27
+ color: undefined,
28
+ style,
29
+ },
30
+ right: {
31
+ color: undefined,
32
+ style,
33
+ },
34
+ top: {
35
+ color: undefined,
36
+ style,
37
+ },
38
+ bottom: {
39
+ color: undefined,
40
+ style,
41
+ },
42
+ };
43
+ }
44
+ else if (aTypeOfJs.isType(options.border, e => ['color', 'style'].some(i => !aTypeOfJs.isUndefined(e[i])))) {
45
+ const border = options.border;
46
+ const style = border.style;
47
+ const color = border.color || undefined;
48
+ // 设置边框并剔除空值
49
+ targetObj.border = JSON.parse(JSON.stringify({
50
+ left: {
51
+ color,
52
+ style,
53
+ },
54
+ right: {
55
+ color,
56
+ style,
57
+ },
58
+ top: {
59
+ color,
60
+ style,
61
+ },
62
+ bottom: {
63
+ color,
64
+ style,
65
+ },
66
+ }, (a, b) => (b === '' ? undefined : b)));
67
+ }
68
+ else if (aTypeOfJs.isType(options.border, e => ['left', 'right', 'top', 'bottom'].some(i => !aTypeOfJs.isUndefined(e[i])))) {
69
+ targetObj.border = options.border;
70
+ }
71
+ }
72
+ }
73
+
74
+ exports.setPro = setPro;
@@ -0,0 +1,83 @@
1
+ import { isUndefined, isNull } from 'a-type-of-js';
2
+ import { createPen } from './createPen.js';
3
+ import { cutoffStringWithChar } from 'color-pen';
4
+ import { lines } from '../lines.js';
5
+ import { terminalResetStyle } from '@color-pen/static';
6
+
7
+ /** 构建表头 */
8
+ function buildBody(body, lineList, hasHeader) {
9
+ /** 结果 */
10
+ let result = '';
11
+ /** 最大的下标 */
12
+ const lineMaxIndex = lineList.length - 1;
13
+ const { fine } = lines;
14
+ lineList.forEach((e, i) => {
15
+ if (i === 0) {
16
+ result += terminalResetStyle;
17
+ result += hasHeader ? fine.lc : fine.lt;
18
+ }
19
+ result += terminalResetStyle;
20
+ result += fine.l.repeat(e + 2);
21
+ if (i === lineMaxIndex) {
22
+ result += terminalResetStyle;
23
+ result += hasHeader ? fine.rc : fine.rt;
24
+ }
25
+ else {
26
+ result += terminalResetStyle;
27
+ result += hasHeader ? fine.c : fine.ct;
28
+ }
29
+ });
30
+ result += '\n';
31
+ body.forEach((row, index) => {
32
+ /** 默认的画笔 (用于绘制空值时的表格) */
33
+ const defaultPen = createPen(row);
34
+ lineList.forEach((e, i) => {
35
+ result += terminalResetStyle;
36
+ result += fine.v;
37
+ /** 当前的元素 */
38
+ const ele = row.data[i];
39
+ // 元素为空则输出默认的样式
40
+ if (isUndefined(ele) || isNull(ele)) {
41
+ result += defaultPen `${'\u2002'.repeat(e + 2)}`;
42
+ }
43
+ else {
44
+ /** 默认的画笔 (用于绘制空值时的表格) */
45
+ const cellPen = createPen(ele);
46
+ let str = ele.content?.toString() || '';
47
+ str = str
48
+ .replace(/[\n]/g, '\\n')
49
+ .replace(/\r/g, '\\r')
50
+ .replace(/\t/g, '\\t');
51
+ result += terminalResetStyle;
52
+ result += cellPen `\u2002${cutoffStringWithChar(str, e)}\u2002`;
53
+ }
54
+ if (i === lineMaxIndex) {
55
+ result += terminalResetStyle;
56
+ result += fine.v;
57
+ }
58
+ });
59
+ result += '\n';
60
+ const isLastRow = body.length - 1 === index;
61
+ lineList.forEach((e, i) => {
62
+ if (i === 0) {
63
+ result += terminalResetStyle;
64
+ result += isLastRow ? fine.lb : fine.lc;
65
+ }
66
+ result += terminalResetStyle;
67
+ result += fine.l.repeat(e + 2);
68
+ if (i === lineMaxIndex) {
69
+ // 最后一行的最后一个
70
+ result += terminalResetStyle;
71
+ result += isLastRow ? fine.rb : fine.rc;
72
+ }
73
+ else {
74
+ result += terminalResetStyle;
75
+ result += isLastRow ? fine.cb : fine.c;
76
+ }
77
+ });
78
+ result += '\n';
79
+ });
80
+ return result;
81
+ }
82
+
83
+ export { buildBody };
@@ -0,0 +1,61 @@
1
+ import { isUndefined, isNull } from 'a-type-of-js';
2
+ import { createPen } from './createPen.js';
3
+ import { cutoffStringWithChar } from 'color-pen';
4
+ import { lines } from '../lines.js';
5
+ import { terminalResetStyle } from '@color-pen/static';
6
+
7
+ /** 构建表头 */
8
+ function buildHeader(header, lineList) {
9
+ /** 结果 */
10
+ let result = '';
11
+ /** 最大的下标 */
12
+ const lineMaxIndex = lineList.length - 1;
13
+ const { fine } = lines;
14
+ /** 默认的画笔 (用于绘制空值时的表格) */
15
+ const defaultPen = createPen(header);
16
+ lineList.forEach((e, i) => {
17
+ if (i === 0) {
18
+ result += fine.lt;
19
+ }
20
+ result += terminalResetStyle;
21
+ result += fine.l.repeat(e + 2);
22
+ if (i === lineMaxIndex) {
23
+ result += terminalResetStyle;
24
+ result += fine.rt;
25
+ }
26
+ else {
27
+ result += terminalResetStyle;
28
+ result += fine.ct;
29
+ }
30
+ });
31
+ result += '\n';
32
+ lineList.forEach((e, i) => {
33
+ result += terminalResetStyle;
34
+ result += fine.v;
35
+ /** 当前的元素 */
36
+ const ele = header.data[i];
37
+ // 元素为空则输出默认的样式
38
+ if (isUndefined(ele) || isNull(ele)) {
39
+ result += terminalResetStyle;
40
+ result += defaultPen('\u2002'.repeat(e + 2));
41
+ }
42
+ else {
43
+ /** 默认的画笔 (用于绘制空值时的表格) */
44
+ const cellPen = createPen(ele);
45
+ let str = ele.content?.toString() ?? '';
46
+ str = str
47
+ .replace(/[\n]/g, '\\n')
48
+ .replace(/\r/g, '\\r')
49
+ .replace(/\t/g, '\\t');
50
+ result += terminalResetStyle;
51
+ result += cellPen `\u2002${cutoffStringWithChar(str, e)}\u2002`;
52
+ }
53
+ if (i === lineMaxIndex) {
54
+ result += fine.v;
55
+ }
56
+ });
57
+ result += '\n';
58
+ return result;
59
+ }
60
+
61
+ export { buildHeader };
@@ -0,0 +1,46 @@
1
+ import { strInTerminalLength } from 'color-pen';
2
+ import { browserEnv, data } from '../global.js';
3
+
4
+ /** 计算得到最大的值 */
5
+ function computerMaxLen(data) {
6
+ const result = [];
7
+ /** 计算 */
8
+ if (data.header) {
9
+ data.header.data.forEach((e, i) => {
10
+ const current = e?.content?.toString() ?? '';
11
+ result[i] = Math.max(result[i] ?? 0, browserEnv ? strInBrowserLength(current) : strInTerminalLength(current));
12
+ });
13
+ }
14
+ if (data.body) {
15
+ data.body.forEach(row => {
16
+ row.data.forEach((e, i) => {
17
+ const current = e?.content?.toString() ?? '';
18
+ result[i] = Math.max(result[i] ?? 0, browserEnv
19
+ ? strInBrowserLength(current)
20
+ : strInTerminalLength(current));
21
+ });
22
+ });
23
+ }
24
+ return result;
25
+ }
26
+ /** 字符串在浏览器环境的字符长度 */
27
+ function strInBrowserLength(str) {
28
+ /** */
29
+ let result = 0;
30
+ [...str].forEach(e => {
31
+ data.emojiRegex.lastIndex = 0;
32
+ data.chineseRegex.lastIndex = 0;
33
+ if (e.match(data.emojiRegex)) {
34
+ result += data.emojiLength;
35
+ }
36
+ else if (e.match(data.chineseRegex)) {
37
+ result += data.chineseLength;
38
+ }
39
+ else {
40
+ result++;
41
+ }
42
+ });
43
+ return Math.ceil(result);
44
+ }
45
+
46
+ export { computerMaxLen };
@@ -0,0 +1,23 @@
1
+ import { isType, isBusinessEmptyString, isUndefined } from 'a-type-of-js';
2
+ import { pen } from 'color-pen';
3
+
4
+ /** 默认的笔 */
5
+ function createPen(options) {
6
+ let defaultPen = pen;
7
+ if (isType(options)) {
8
+ if (options.bold)
9
+ defaultPen = defaultPen.bold;
10
+ if (!isBusinessEmptyString(options.bgColor) &&
11
+ !isUndefined(options.bgColor))
12
+ defaultPen = defaultPen.bgColor(options.bgColor);
13
+ if (!isBusinessEmptyString(options.color) && !isUndefined(options.color))
14
+ defaultPen = defaultPen.color(options.color);
15
+ if (options.italic)
16
+ defaultPen = defaultPen.italic;
17
+ if (options.underline)
18
+ defaultPen = defaultPen.underline;
19
+ }
20
+ return defaultPen;
21
+ }
22
+
23
+ export { createPen };
@@ -0,0 +1,54 @@
1
+ import { colorText, strInTerminalLength } from 'color-pen';
2
+ import { buildBody } from './buildBody.js';
3
+ import { buildHeader } from './buildHeader.js';
4
+ import { computerMaxLen } from './computerMaxLen.js';
5
+ import { browserEnv, data } from '../global.js';
6
+
7
+ /** 渲染 */
8
+ function render(table, fontSize) {
9
+ /** 获取每一行最大宽度的元素的宽度组成的数组 */
10
+ const lineLen = computerMaxLen(table);
11
+ /** 是否有表头 */
12
+ let hasHeader = false;
13
+ let buildStr = '';
14
+ // 构建表头
15
+ if (table.header) {
16
+ hasHeader = true;
17
+ buildStr += buildHeader(table.header, lineLen);
18
+ }
19
+ buildStr += buildBody(table.body, lineLen, hasHeader);
20
+ /** 彩色数组 */
21
+ const colorTextArr = colorText(buildStr);
22
+ if (browserEnv) {
23
+ const strList = colorTextArr[0].split('%c');
24
+ const result = colorTextArr.map((e, i) => {
25
+ if (i > 0) {
26
+ /** 构建最小的单位的组 */
27
+ const doubleByteCharNumber = [...strList[i]].reduce((v, e) => {
28
+ if (strInTerminalLength(e) > 1) {
29
+ data.emojiRegex.lastIndex = 0;
30
+ if (e.match(data.emojiRegex))
31
+ return v - (data.emojiLength - 2);
32
+ return v + (2 - data.chineseLength);
33
+ }
34
+ return v;
35
+ }, 0);
36
+ const newStr = e +
37
+ "font-family: Consolas,Monaco,Courier,'Courier New','等宽字体',monospace; font-size:" +
38
+ fontSize +
39
+ 'px;word-spacing:normal;padding:0;margin:0;padding-right:' +
40
+ doubleByteCharNumber * fontSize +
41
+ 'px';
42
+ return newStr;
43
+ }
44
+ return e;
45
+ });
46
+ /// 渲染表格
47
+ console.log(...result);
48
+ }
49
+ else {
50
+ console.log(...colorTextArr);
51
+ }
52
+ }
53
+
54
+ export { render };
package/es/core.js ADDED
@@ -0,0 +1,49 @@
1
+ import { createHeaderProto } from './proto/createHeaderProto.js';
2
+ import { parse } from './parse/parse.js';
3
+ import { parseRow } from './parse/parseRow.js';
4
+ import { render } from './build/index.js';
5
+
6
+ /** 构建一个用于控制台的表格 */
7
+ function table(options) {
8
+ /** 构建初始化配置的表单 */
9
+ const [tableEle, tablePro] = parse(options);
10
+ let fontSize = 12;
11
+ /**
12
+ * 核心技能
13
+ *
14
+ * 这里将构建表格
15
+ *
16
+ *
17
+ */
18
+ const core = () => render(tableEle, fontSize);
19
+ Object.setPrototypeOf(core, this);
20
+ Object.defineProperties(core, {
21
+ addRow: {
22
+ value: (data) => {
23
+ tableEle.body.push(parseRow(data, tablePro));
24
+ return core;
25
+ },
26
+ configurable: false,
27
+ writable: false,
28
+ enumerable: false,
29
+ },
30
+ setHeader: {
31
+ value: (data) => {
32
+ tableEle.header = parseRow(data, createHeaderProto(tablePro));
33
+ return core;
34
+ },
35
+ configurable: false,
36
+ writable: false,
37
+ enumerable: false,
38
+ },
39
+ setFontSize: {
40
+ value: (_fontSize) => {
41
+ fontSize = _fontSize;
42
+ return core;
43
+ },
44
+ },
45
+ });
46
+ return core;
47
+ }
48
+
49
+ export { table };
@@ -0,0 +1,10 @@
1
+ import { createConstructor } from 'a-js-tools';
2
+
3
+ /** 构建行 原始类 */
4
+ const RowEleClass = createConstructor(function (proto) {
5
+ this.data = [];
6
+ Object.setPrototypeOf(this, proto);
7
+ return this;
8
+ });
9
+
10
+ export { RowEleClass };
@@ -0,0 +1,11 @@
1
+ import { createConstructor } from 'a-js-tools';
2
+
3
+ /** TableEleClass 类,原始构建类 */
4
+ const TableEleClass = createConstructor(function (proto) {
5
+ this.body = [];
6
+ this.header = undefined;
7
+ Object.setPrototypeOf(this, proto);
8
+ return this;
9
+ });
10
+
11
+ export { TableEleClass };
package/es/global.js ADDED
@@ -0,0 +1,49 @@
1
+ import { isNode } from 'a-js-tools';
2
+
3
+ /** 浏览器环境 */
4
+ const browserEnv = !isNode();
5
+ const data = {
6
+ emojiLength: 2.08,
7
+ emojiRegex: /[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F900}-\u{1F9FF}]/gu,
8
+ chineseLength: 1.8,
9
+ /** 中文的正则 */
10
+ chineseRegex: /[\u4E00-\u9FFF]/g,
11
+ };
12
+ /** 全局的属性 */
13
+ class ColoredTableGlobalData {
14
+ align = 'left';
15
+ color = '';
16
+ bgColor = '';
17
+ bold = false;
18
+ underline = false;
19
+ italic = false;
20
+ border = {
21
+ left: {
22
+ color: undefined,
23
+ style: 'simple',
24
+ },
25
+ right: {
26
+ color: undefined,
27
+ style: 'simple',
28
+ },
29
+ top: {
30
+ color: undefined,
31
+ style: 'simple',
32
+ },
33
+ bottom: {
34
+ color: undefined,
35
+ style: 'simple',
36
+ },
37
+ };
38
+ }
39
+ /**
40
+ *
41
+ * 全局 table 配置
42
+ *
43
+ * 若没有其他特殊说名,将使用该数据作为最终的渲染依据
44
+ *
45
+ * 即为默认属性
46
+ */
47
+ const globalData = new ColoredTableGlobalData();
48
+
49
+ export { browserEnv, data, globalData };
package/es/index.js ADDED
@@ -0,0 +1,16 @@
1
+ import { createConstructor } from 'a-js-tools';
2
+ import { table } from './core.js';
3
+ export { globalData as ColoredTableGlobalData } from './global.js';
4
+
5
+ /**
6
+ *
7
+ * # 构建 DIY 表单
8
+ *
9
+ * 使用 console.table 构建的表单默认不支持彩色文本(目前我没找到支持的方法),遂花几日写该方法
10
+ *
11
+ *
12
+ *
13
+ */
14
+ const tableClass = createConstructor(table);
15
+
16
+ export { tableClass as ColoredTable, tableClass as Table };
package/es/lines.js ADDED
@@ -0,0 +1,17 @@
1
+ const lines = {
2
+ fine: {
3
+ lt: '┌',
4
+ ct: '┬',
5
+ rt: '┐',
6
+ lc: '├',
7
+ c: '┼',
8
+ rc: '┤',
9
+ lb: '└',
10
+ cb: '┴',
11
+ rb: '┘',
12
+ l: '─',
13
+ v: '│',
14
+ },
15
+ };
16
+
17
+ export { lines };
@@ -0,0 +1,42 @@
1
+ import { isUndefined, isArray } from 'a-type-of-js';
2
+ import { globalData } from '../global.js';
3
+ import { setPro } from '../proto/setPro.js';
4
+ import { TableEleClass } from '../ele/tableEle.js';
5
+ import { parseRow } from './parseRow.js';
6
+ import { createHeaderProto } from '../proto/createHeaderProto.js';
7
+
8
+ /** 表格的 */
9
+ class TableProto {
10
+ }
11
+ /**
12
+ *
13
+ * 解析并转化(可选)参数为定值属性
14
+ *
15
+ */
16
+ function parse(options) {
17
+ // 初始化时可为空(undefined)
18
+ if (isUndefined(options)) {
19
+ options = {};
20
+ }
21
+ // 数组参数转化为对象
22
+ if (isArray(options)) {
23
+ options = {
24
+ body: options,
25
+ };
26
+ }
27
+ /** 表格的原型属性 */
28
+ const tableProto = new TableProto();
29
+ // 将在 options 上配置的属性配置到原型上
30
+ setPro(tableProto, options);
31
+ Object.setPrototypeOf(tableProto, globalData);
32
+ // 创建表格
33
+ const table = new TableEleClass(tableProto);
34
+ // 解析表头
35
+ if (options.header)
36
+ table.header = parseRow(options.header, createHeaderProto(tableProto));
37
+ /** 解析表干 */
38
+ options.body?.forEach(e => table.body.push(parseRow(e, tableProto)));
39
+ return [table, tableProto];
40
+ }
41
+
42
+ export { parse };
@@ -0,0 +1,25 @@
1
+ import { isUndefined, isType, isPlainObject } from 'a-type-of-js';
2
+ import { setPro } from '../proto/setPro.js';
3
+
4
+ /** 解析为单元格 */
5
+ function parseCell(data, parentPro) {
6
+ // 空值直接返回空
7
+ if (isUndefined(data)) {
8
+ return undefined;
9
+ }
10
+ // 直接值转化为对象值,方便后续统一处理
11
+ if (isType(data, i => !isPlainObject(i))) {
12
+ data = {
13
+ content: data,
14
+ };
15
+ }
16
+ /** 单元格的属性 */
17
+ const cell = {
18
+ content: data.content,
19
+ }; // 其他的属性在下面的 `setPro` 中进行给值
20
+ setPro(cell, data); // 构建属性的值
21
+ Object.setPrototypeOf(cell, parentPro);
22
+ return cell;
23
+ }
24
+
25
+ export { parseCell };
@@ -0,0 +1,32 @@
1
+ import { isArray } from 'a-type-of-js';
2
+ import { RowEleClass } from '../ele/rowEle.js';
3
+ import { setPro } from '../proto/setPro.js';
4
+ import { parseCell } from './parseCell.js';
5
+
6
+ /** 表格的行原型 */
7
+ class RowProto {
8
+ }
9
+ /**
10
+ * 解析行
11
+ *
12
+ * @param data 行数据
13
+ * @param parentPro 父级的属性参数
14
+ */
15
+ function parseRow(data, parentPro) {
16
+ // 数组转化为对,方便后续统一处理
17
+ if (isArray(data))
18
+ data = { data };
19
+ /** 表格的原型属性 */
20
+ const rowProto = new RowProto();
21
+ setPro(rowProto, data); // 设置已配置的属性
22
+ /** 行数据 */
23
+ const result = new RowEleClass(rowProto);
24
+ Object.setPrototypeOf(rowProto, parentPro);
25
+ data.data?.forEach(e => {
26
+ if (e)
27
+ result.data.push(parseCell(e, rowProto));
28
+ });
29
+ return result;
30
+ }
31
+
32
+ export { RowProto, parseRow };
@@ -0,0 +1,31 @@
1
+ import { RowProto } from '../parse/parseRow.js';
2
+
3
+ /** 表头 */
4
+ class HeaderProto extends RowProto {
5
+ border = {
6
+ left: {
7
+ style: 'bold',
8
+ color: undefined,
9
+ },
10
+ right: {
11
+ style: 'bold',
12
+ color: undefined,
13
+ },
14
+ top: {
15
+ style: 'bold',
16
+ color: undefined,
17
+ },
18
+ bottom: {
19
+ style: 'bold',
20
+ color: undefined,
21
+ },
22
+ };
23
+ }
24
+ /** 设置 header 的原型 */
25
+ function createHeaderProto(tableProto) {
26
+ const headerProto = new HeaderProto();
27
+ Object.setPrototypeOf(headerProto, tableProto);
28
+ return headerProto;
29
+ }
30
+
31
+ export { createHeaderProto };