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.
- package/LICENSE +3 -3
- package/README.md +3 -11
- package/cjs/build/buildBody.js +85 -0
- package/cjs/build/buildHeader.js +63 -0
- package/cjs/build/computerMaxLen.js +48 -0
- package/cjs/build/createPen.js +25 -0
- package/cjs/build/index.js +56 -0
- package/cjs/core.js +51 -0
- package/cjs/ele/rowEle.js +12 -0
- package/cjs/ele/tableEle.js +13 -0
- package/cjs/global.js +53 -0
- package/cjs/index.js +20 -0
- package/cjs/lines.js +19 -0
- package/cjs/parse/parse.js +44 -0
- package/cjs/parse/parseCell.js +27 -0
- package/cjs/parse/parseRow.js +35 -0
- package/cjs/proto/createHeaderProto.js +33 -0
- package/cjs/proto/setPro.js +74 -0
- package/es/build/buildBody.js +83 -0
- package/es/build/buildHeader.js +61 -0
- package/es/build/computerMaxLen.js +46 -0
- package/es/build/createPen.js +23 -0
- package/es/build/index.js +54 -0
- package/es/core.js +49 -0
- package/es/ele/rowEle.js +10 -0
- package/es/ele/tableEle.js +11 -0
- package/es/global.js +49 -0
- package/es/index.js +16 -0
- package/es/lines.js +17 -0
- package/es/parse/parse.js +42 -0
- package/es/parse/parseCell.js +25 -0
- package/es/parse/parseRow.js +32 -0
- package/es/proto/createHeaderProto.js +31 -0
- package/es/proto/setPro.js +72 -0
- package/{index.d.ts → es/src/index.d.ts} +3 -3
- package/package.json +37 -34
- package/index.cjs +0 -1
- package/index.mjs +0 -1
- /package/{src → es/src}/build/buildBody.d.ts +0 -0
- /package/{src → es/src}/build/buildHeader.d.ts +0 -0
- /package/{src → es/src}/build/computerMaxLen.d.ts +0 -0
- /package/{src → es/src}/build/createPen.d.ts +0 -0
- /package/{src → es/src}/build/index.d.ts +0 -0
- /package/{src → es/src}/core.d.ts +0 -0
- /package/{src → es/src}/ele/rowEle.d.ts +0 -0
- /package/{src → es/src}/ele/tableEle.d.ts +0 -0
- /package/{src → es/src}/global.d.ts +0 -0
- /package/{src → es/src}/lines.d.ts +0 -0
- /package/{src → es/src}/parse/parse.d.ts +0 -0
- /package/{src → es/src}/parse/parseCell.d.ts +0 -0
- /package/{src → es/src}/parse/parseRow.d.ts +0 -0
- /package/{src → es/src}/proto/createHeaderProto.d.ts +0 -0
- /package/{src → es/src}/proto/setPro.d.ts +0 -0
- /package/{src → es/src}/types.d.ts +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { isType, isString, isUndefined } from 'a-type-of-js';
|
|
2
|
+
|
|
3
|
+
/** 配置原型上的属性 */
|
|
4
|
+
function setPro(targetObj, options) {
|
|
5
|
+
if (options.align) {
|
|
6
|
+
targetObj.align = options.align;
|
|
7
|
+
}
|
|
8
|
+
if (options.bgColor) {
|
|
9
|
+
targetObj.bgColor = options.bgColor;
|
|
10
|
+
}
|
|
11
|
+
if (options.color) {
|
|
12
|
+
targetObj.color = options.color;
|
|
13
|
+
}
|
|
14
|
+
if (options.italic) {
|
|
15
|
+
targetObj.italic = options.italic;
|
|
16
|
+
}
|
|
17
|
+
if (options.underline) {
|
|
18
|
+
targetObj.underline = options.underline;
|
|
19
|
+
}
|
|
20
|
+
if (options.border) {
|
|
21
|
+
if (isType(options.border, e => isString(e))) {
|
|
22
|
+
const style = options.border;
|
|
23
|
+
targetObj.border = {
|
|
24
|
+
left: {
|
|
25
|
+
color: undefined,
|
|
26
|
+
style,
|
|
27
|
+
},
|
|
28
|
+
right: {
|
|
29
|
+
color: undefined,
|
|
30
|
+
style,
|
|
31
|
+
},
|
|
32
|
+
top: {
|
|
33
|
+
color: undefined,
|
|
34
|
+
style,
|
|
35
|
+
},
|
|
36
|
+
bottom: {
|
|
37
|
+
color: undefined,
|
|
38
|
+
style,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
else if (isType(options.border, e => ['color', 'style'].some(i => !isUndefined(e[i])))) {
|
|
43
|
+
const border = options.border;
|
|
44
|
+
const style = border.style;
|
|
45
|
+
const color = border.color || undefined;
|
|
46
|
+
// 设置边框并剔除空值
|
|
47
|
+
targetObj.border = JSON.parse(JSON.stringify({
|
|
48
|
+
left: {
|
|
49
|
+
color,
|
|
50
|
+
style,
|
|
51
|
+
},
|
|
52
|
+
right: {
|
|
53
|
+
color,
|
|
54
|
+
style,
|
|
55
|
+
},
|
|
56
|
+
top: {
|
|
57
|
+
color,
|
|
58
|
+
style,
|
|
59
|
+
},
|
|
60
|
+
bottom: {
|
|
61
|
+
color,
|
|
62
|
+
style,
|
|
63
|
+
},
|
|
64
|
+
}, (a, b) => (b === '' ? undefined : b)));
|
|
65
|
+
}
|
|
66
|
+
else if (isType(options.border, e => ['left', 'right', 'top', 'bottom'].some(i => !isUndefined(e[i])))) {
|
|
67
|
+
targetObj.border = options.border;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export { setPro };
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
|
-
declare const tableClass: import("a-js-tools").CreateConstructor<import("./
|
|
10
|
+
declare const tableClass: import("a-js-tools").CreateConstructor<import("./types").ColoredTable, [options?: import("./types").ColoredTableOptions]>;
|
|
11
11
|
export { tableClass as ColoredTable, tableClass as Table };
|
|
12
|
-
export type { ColoredTableCellValue, ColoredTableBorderStyle, ColoredTableUnilateralBorder, ColoredTableUnilateralBorderOptions, ColoredTableBorder, ColoredTableBorderOptions, ColoredBorderOptions, ColoredTableContentAlign, ColoredTableCommon, ColoredTableCommonOption, ColoredTableCellNoBorder, ColoredTableCell, ColoredTableRowOption, ColoredTableEle, ColoredTableOptions, } from './
|
|
13
|
-
export { globalData as ColoredTableGlobalData } from './
|
|
12
|
+
export type { ColoredTableCellValue, ColoredTableBorderStyle, ColoredTableUnilateralBorder, ColoredTableUnilateralBorderOptions, ColoredTableBorder, ColoredTableBorderOptions, ColoredBorderOptions, ColoredTableContentAlign, ColoredTableCommon, ColoredTableCommonOption, ColoredTableCellNoBorder, ColoredTableCell, ColoredTableRowOption, ColoredTableEle, ColoredTableOptions, } from './types';
|
|
13
|
+
export { globalData as ColoredTableGlobalData } from './global';
|
package/package.json
CHANGED
|
@@ -1,55 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "colored-table",
|
|
3
|
+
"version": "0.2.0",
|
|
3
4
|
"type": "module",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"dependencies": {
|
|
8
|
-
"@color-pen/static": "^1.0.0",
|
|
9
|
-
"a-js-tools": "^1.0.8",
|
|
10
|
-
"a-type-of-js": "^1.0.5",
|
|
11
|
-
"color-pen": "^2.0.12"
|
|
12
|
-
},
|
|
5
|
+
"main": "cjs/index.js",
|
|
6
|
+
"module": "es/index.js",
|
|
7
|
+
"types": "es/src/index.d.ts",
|
|
13
8
|
"author": {
|
|
14
|
-
"name": "
|
|
15
|
-
"email": "
|
|
9
|
+
"name": "泥豆君",
|
|
10
|
+
"email": "Mr.MudBean@outlook.com",
|
|
16
11
|
"url": "https://earthnut.dev"
|
|
17
12
|
},
|
|
13
|
+
"description": "一个简单的在控制台及控制台构建彩色文本表格的工具",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"license": "MIT",
|
|
18
16
|
"files": [
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
17
|
+
"cjs",
|
|
18
|
+
"es",
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"README.md"
|
|
23
21
|
],
|
|
24
22
|
"exports": {
|
|
25
23
|
".": {
|
|
26
|
-
"import":
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"require": {
|
|
31
|
-
"default": "./index.cjs",
|
|
32
|
-
"types": "./index.d.ts"
|
|
33
|
-
}
|
|
24
|
+
"import": "./es/index.js",
|
|
25
|
+
"default": "./es/index.js",
|
|
26
|
+
"require": "./cjs/index.js",
|
|
27
|
+
"types": "./es/src/index.d.ts"
|
|
34
28
|
}
|
|
35
29
|
},
|
|
36
30
|
"keywords": [
|
|
37
|
-
"colored
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
31
|
+
"colored table",
|
|
32
|
+
"终端",
|
|
33
|
+
"彩色表格",
|
|
34
|
+
"控制台",
|
|
35
|
+
"terminal"
|
|
41
36
|
],
|
|
42
|
-
"homepage": "https://earthnut.dev/colored-table",
|
|
37
|
+
"homepage": "https://earthnut.dev/npm/colored-table",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@color-pen/static": "^1.1.1",
|
|
40
|
+
"a-js-tools": "^2.0.1",
|
|
41
|
+
"a-type-of-js": "^2.0.0",
|
|
42
|
+
"color-pen": "^3.0.0"
|
|
43
|
+
},
|
|
43
44
|
"bugs": {
|
|
44
|
-
"url": "https://github.com/
|
|
45
|
-
"email": "
|
|
45
|
+
"url": "https://github.com/MrMudBean/colored-table/issues",
|
|
46
|
+
"email": "Mr.MudBean@outlook.com"
|
|
46
47
|
},
|
|
47
48
|
"repository": {
|
|
48
49
|
"type": "git",
|
|
49
|
-
"url": "git+https://github.com/
|
|
50
|
+
"url": "git+https://github.com/MrMudBean/colored-table.git"
|
|
50
51
|
},
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
52
|
+
"browserslist": [
|
|
53
|
+
"last 2"
|
|
54
|
+
],
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=18.0.0"
|
|
54
57
|
}
|
|
55
58
|
}
|
package/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("a-js-tools"),t=require("a-type-of-js"),o=require("color-pen"),r=require("@color-pen/static");const n=e.createConstructor(function(e){return this.data=[],Object.setPrototypeOf(this,e),this});function l(e,o){if(o.align&&(e.align=o.align),o.bgColor&&(e.bgColor=o.bgColor),o.color&&(e.color=o.color),o.italic&&(e.italic=o.italic),o.underline&&(e.underline=o.underline),o.border)if(t.isType(o.border,e=>t.isString(e))){const t=o.border;e.border={left:{color:void 0,style:t},right:{color:void 0,style:t},top:{color:void 0,style:t},bottom:{color:void 0,style:t}}}else if(t.isType(o.border,e=>["color","style"].some(o=>!t.isUndefined(e[o])))){const t=o.border,r=t.style,n=t.color||void 0;e.border=JSON.parse(JSON.stringify({left:{color:n,style:r},right:{color:n,style:r},top:{color:n,style:r},bottom:{color:n,style:r}},(e,t)=>""===t?void 0:t))}else t.isType(o.border,e=>["left","right","top","bottom"].some(o=>!t.isUndefined(e[o])))&&(e.border=o.border)}class i{}function s(e,o){t.isArray(e)&&(e={data:e});const r=new i;l(r,e);const s=new n(r);return Object.setPrototypeOf(r,o),e.data?.forEach(e=>{e&&s.data.push(function(e,o){if(t.isUndefined(e))return;t.isType(e,e=>!t.isPlainObject(e))&&(e={content:e});const r={content:e.content};return l(r,e),Object.setPrototypeOf(r,o),r}(e,r))}),s}class c extends i{border={left:{style:"bold",color:void 0},right:{style:"bold",color:void 0},top:{style:"bold",color:void 0},bottom:{style:"bold",color:void 0}}}function a(e){const t=new c;return Object.setPrototypeOf(t,e),t}const d=!e.isNode(),u={emojiLength:2.08,emojiRegex:/[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F900}-\u{1F9FF}]/gu,chineseLength:1.8,chineseRegex:/[\u4E00-\u9FFF]/g};const f=new class{align="left";color="";bgColor="";bold=!1;underline=!1;italic=!1;border={left:{color:void 0,style:"simple"},right:{color:void 0,style:"simple"},top:{color:void 0,style:"simple"},bottom:{color:void 0,style:"simple"}}},h=e.createConstructor(function(e){return this.body=[],this.header=void 0,Object.setPrototypeOf(this,e),this});class b{}function g(e){let r=o.pen;return t.isType(e)&&(e.bold&&(r=r.bold),t.isBusinessEmptyString(e.bgColor)||t.isUndefined(e.bgColor)||(r=r.bgColor(e.bgColor)),t.isBusinessEmptyString(e.color)||t.isUndefined(e.color)||(r=r.color(e.color)),e.italic&&(r=r.italic),e.underline&&(r=r.underline)),r}const y={fine:{lt:"┌",ct:"┬",rt:"┐",lc:"├",c:"┼",rc:"┤",lb:"└",cb:"┴",rb:"┘",l:"─",v:"│"}};function p(e){let t=0;return[...e].forEach(e=>{u.emojiRegex.lastIndex=0,u.chineseRegex.lastIndex=0,e.match(u.emojiRegex)?t+=u.emojiLength:e.match(u.chineseRegex)?t+=u.chineseLength:t++}),Math.ceil(t)}function m(e,n){const l=function(e){const t=[];return e.header&&e.header.data.forEach((e,r)=>{const n=e?.content?.toString()??"";t[r]=Math.max(t[r]??0,d?p(n):o.strInTerminalLength(n))}),e.body&&e.body.forEach(e=>{e.data.forEach((e,r)=>{const n=e?.content?.toString()??"";t[r]=Math.max(t[r]??0,d?p(n):o.strInTerminalLength(n))})}),t}(e);let i=!1,s="";e.header&&(i=!0,s+=function(e,n){let l="";const i=n.length-1,{fine:s}=y,c=g(e);return n.forEach((e,t)=>{0===t&&(l+=s.lt),l+=r.terminalResetStyle,l+=s.l.repeat(e+2),t===i?(l+=r.terminalResetStyle,l+=s.rt):(l+=r.terminalResetStyle,l+=s.ct)}),l+="\n",n.forEach((n,a)=>{l+=r.terminalResetStyle,l+=s.v;const d=e.data[a];if(t.isUndefined(d)||t.isNull(d))l+=r.terminalResetStyle,l+=c(" ".repeat(n+2));else{const e=g(d);let t=d.content?.toString()??"";t=t.replace(/[\n]/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"),l+=r.terminalResetStyle,l+=e`\u2002${o.cutoffStringWithChar(t,n)}\u2002`}a===i&&(l+=s.v)}),l+="\n",l}(e.header,l)),s+=function(e,n,l){let i="";const s=n.length-1,{fine:c}=y;return n.forEach((e,t)=>{0===t&&(i+=r.terminalResetStyle,i+=l?c.lc:c.lt),i+=r.terminalResetStyle,i+=c.l.repeat(e+2),t===s?(i+=r.terminalResetStyle,i+=l?c.rc:c.rt):(i+=r.terminalResetStyle,i+=l?c.c:c.ct)}),i+="\n",e.forEach((l,a)=>{const d=g(l);n.forEach((e,n)=>{i+=r.terminalResetStyle,i+=c.v;const a=l.data[n];if(t.isUndefined(a)||t.isNull(a))i+=d`${" ".repeat(e+2)}`;else{const t=g(a);let n=a.content?.toString()||"";n=n.replace(/[\n]/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"),i+=r.terminalResetStyle,i+=t`\u2002${o.cutoffStringWithChar(n,e)}\u2002`}n===s&&(i+=r.terminalResetStyle,i+=c.v)}),i+="\n";const u=e.length-1===a;n.forEach((e,t)=>{0===t&&(i+=r.terminalResetStyle,i+=u?c.lb:c.lc),i+=r.terminalResetStyle,i+=c.l.repeat(e+2),t===s?(i+=r.terminalResetStyle,i+=u?c.rb:c.rc):(i+=r.terminalResetStyle,i+=u?c.cb:c.c)}),i+="\n"}),i}(e.body,l,i);const c=o.colorText(s);if(d){const e=c[0].split("%c"),t=c.map((t,r)=>{if(r>0){const l=[...e[r]].reduce((e,t)=>o.strInTerminalLength(t)>1?(u.emojiRegex.lastIndex=0,t.match(u.emojiRegex)?e-(u.emojiLength-2):e+(2-u.chineseLength)):e,0);return t+"font-family: Consolas,Monaco,Courier,'Courier New','等宽字体',monospace; font-size:"+n+"px;word-spacing:normal;padding:0;margin:0;padding-right:"+l*n+"px"}return t});console.log(...t)}else console.log(...c)}const S=e.createConstructor(function(e){const[o,r]=function(e){t.isUndefined(e)&&(e={}),t.isArray(e)&&(e={body:e});const o=new b;l(o,e),Object.setPrototypeOf(o,f);const r=new h(o);return e.header&&(r.header=s(e.header,a(o))),e.body?.forEach(e=>r.body.push(s(e,o))),[r,o]}(e);let n=12;const i=()=>m(o,n);return Object.setPrototypeOf(i,this),Object.defineProperties(i,{addRow:{value:e=>(o.body.push(s(e,r)),i),configurable:!1,writable:!1,enumerable:!1},setHeader:{value:e=>(o.header=s(e,a(r)),i),configurable:!1,writable:!1,enumerable:!1},setFontSize:{value:e=>(n=e,i)}}),i});exports.ColoredTable=S,exports.ColoredTableGlobalData=f,exports.Table=S;
|
package/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createConstructor as o,isNode as e}from"a-js-tools";import{isType as t,isString as r,isUndefined as n,isPlainObject as l,isArray as c,isBusinessEmptyString as i,isNull as s}from"a-type-of-js";import{pen as a,cutoffStringWithChar as d,strInTerminalLength as b,colorText as u}from"color-pen";import{terminalResetStyle as f}from"@color-pen/static";const h=o(function(o){return this.data=[],Object.setPrototypeOf(this,o),this});function g(o,e){if(e.align&&(o.align=e.align),e.bgColor&&(o.bgColor=e.bgColor),e.color&&(o.color=e.color),e.italic&&(o.italic=e.italic),e.underline&&(o.underline=e.underline),e.border)if(t(e.border,o=>r(o))){const t=e.border;o.border={left:{color:void 0,style:t},right:{color:void 0,style:t},top:{color:void 0,style:t},bottom:{color:void 0,style:t}}}else if(t(e.border,o=>["color","style"].some(e=>!n(o[e])))){const t=e.border,r=t.style,n=t.color||void 0;o.border=JSON.parse(JSON.stringify({left:{color:n,style:r},right:{color:n,style:r},top:{color:n,style:r},bottom:{color:n,style:r}},(o,e)=>""===e?void 0:e))}else t(e.border,o=>["left","right","top","bottom"].some(e=>!n(o[e])))&&(o.border=e.border)}class p{}function m(o,e){c(o)&&(o={data:o});const r=new p;g(r,o);const i=new h(r);return Object.setPrototypeOf(r,e),o.data?.forEach(o=>{o&&i.data.push(function(o,e){if(n(o))return;t(o,o=>!l(o))&&(o={content:o});const r={content:o.content};return g(r,o),Object.setPrototypeOf(r,e),r}(o,r))}),i}class y extends p{border={left:{style:"bold",color:void 0},right:{style:"bold",color:void 0},top:{style:"bold",color:void 0},bottom:{style:"bold",color:void 0}}}function v(o){const e=new y;return Object.setPrototypeOf(e,o),e}const F=!e(),j={emojiLength:2.08,emojiRegex:/[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F900}-\u{1F9FF}]/gu,chineseLength:1.8,chineseRegex:/[\u4E00-\u9FFF]/g};const x=new class{align="left";color="";bgColor="";bold=!1;underline=!1;italic=!1;border={left:{color:void 0,style:"simple"},right:{color:void 0,style:"simple"},top:{color:void 0,style:"simple"},bottom:{color:void 0,style:"simple"}}},O=o(function(o){return this.body=[],this.header=void 0,Object.setPrototypeOf(this,o),this});class C{}function E(o){let e=a;return t(o)&&(o.bold&&(e=e.bold),i(o.bgColor)||n(o.bgColor)||(e=e.bgColor(o.bgColor)),i(o.color)||n(o.color)||(e=e.color(o.color)),o.italic&&(e=e.italic),o.underline&&(e=e.underline)),e}const w={fine:{lt:"┌",ct:"┬",rt:"┐",lc:"├",c:"┼",rc:"┤",lb:"└",cb:"┴",rb:"┘",l:"─",v:"│"}};function R(o){let e=0;return[...o].forEach(o=>{j.emojiRegex.lastIndex=0,j.chineseRegex.lastIndex=0,o.match(j.emojiRegex)?e+=j.emojiLength:o.match(j.chineseRegex)?e+=j.chineseLength:e++}),Math.ceil(e)}function P(o,e){const t=function(o){const e=[];return o.header&&o.header.data.forEach((o,t)=>{const r=o?.content?.toString()??"";e[t]=Math.max(e[t]??0,F?R(r):b(r))}),o.body&&o.body.forEach(o=>{o.data.forEach((o,t)=>{const r=o?.content?.toString()??"";e[t]=Math.max(e[t]??0,F?R(r):b(r))})}),e}(o);let r=!1,l="";o.header&&(r=!0,l+=function(o,e){let t="";const r=e.length-1,{fine:l}=w,c=E(o);return e.forEach((o,e)=>{0===e&&(t+=l.lt),t+=f,t+=l.l.repeat(o+2),e===r?(t+=f,t+=l.rt):(t+=f,t+=l.ct)}),t+="\n",e.forEach((e,i)=>{t+=f,t+=l.v;const a=o.data[i];if(n(a)||s(a))t+=f,t+=c(" ".repeat(e+2));else{const o=E(a);let r=a.content?.toString()??"";r=r.replace(/[\n]/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"),t+=f,t+=o`\u2002${d(r,e)}\u2002`}i===r&&(t+=l.v)}),t+="\n",t}(o.header,t)),l+=function(o,e,t){let r="";const l=e.length-1,{fine:c}=w;return e.forEach((o,e)=>{0===e&&(r+=f,r+=t?c.lc:c.lt),r+=f,r+=c.l.repeat(o+2),e===l?(r+=f,r+=t?c.rc:c.rt):(r+=f,r+=t?c.c:c.ct)}),r+="\n",o.forEach((t,i)=>{const a=E(t);e.forEach((o,e)=>{r+=f,r+=c.v;const i=t.data[e];if(n(i)||s(i))r+=a`${" ".repeat(o+2)}`;else{const e=E(i);let t=i.content?.toString()||"";t=t.replace(/[\n]/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"),r+=f,r+=e`\u2002${d(t,o)}\u2002`}e===l&&(r+=f,r+=c.v)}),r+="\n";const b=o.length-1===i;e.forEach((o,e)=>{0===e&&(r+=f,r+=b?c.lb:c.lc),r+=f,r+=c.l.repeat(o+2),e===l?(r+=f,r+=b?c.rb:c.rc):(r+=f,r+=b?c.cb:c.c)}),r+="\n"}),r}(o.body,t,r);const c=u(l);if(F){const o=c[0].split("%c"),t=c.map((t,r)=>{if(r>0){const n=[...o[r]].reduce((o,e)=>b(e)>1?(j.emojiRegex.lastIndex=0,e.match(j.emojiRegex)?o-(j.emojiLength-2):o+(2-j.chineseLength)):o,0);return t+"font-family: Consolas,Monaco,Courier,'Courier New','等宽字体',monospace; font-size:"+e+"px;word-spacing:normal;padding:0;margin:0;padding-right:"+n*e+"px"}return t});console.log(...t)}else console.log(...c)}const S=o(function(o){const[e,t]=function(o){n(o)&&(o={}),c(o)&&(o={body:o});const e=new C;g(e,o),Object.setPrototypeOf(e,x);const t=new O(e);return o.header&&(t.header=m(o.header,v(e))),o.body?.forEach(o=>t.body.push(m(o,e))),[t,e]}(o);let r=12;const l=()=>P(e,r);return Object.setPrototypeOf(l,this),Object.defineProperties(l,{addRow:{value:o=>(e.body.push(m(o,t)),l),configurable:!1,writable:!1,enumerable:!1},setHeader:{value:o=>(e.header=m(o,v(t)),l),configurable:!1,writable:!1,enumerable:!1},setFontSize:{value:o=>(r=o,l)}}),l});export{S as ColoredTable,x as ColoredTableGlobalData,S as Table};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|