colored-table 0.0.2 → 0.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/LICENSE +2 -2
- package/README.md +14 -2
- package/index.cjs +20 -1
- package/index.mjs +16 -1
- package/package.json +31 -21
- package/src/build/buildBody.cjs +85 -0
- package/src/build/buildBody.mjs +83 -0
- package/src/build/buildHeader.cjs +63 -0
- package/src/build/buildHeader.mjs +61 -0
- package/src/build/computerMaxLen.cjs +48 -0
- package/src/build/computerMaxLen.mjs +46 -0
- package/src/build/createPen.cjs +25 -0
- package/src/build/createPen.mjs +23 -0
- package/src/build/index.cjs +56 -0
- package/src/build/index.mjs +54 -0
- package/src/core.cjs +51 -0
- package/src/core.mjs +49 -0
- package/src/ele/rowEle.cjs +12 -0
- package/src/ele/rowEle.mjs +10 -0
- package/src/ele/tableEle.cjs +13 -0
- package/src/ele/tableEle.mjs +11 -0
- package/src/global.cjs +53 -0
- package/src/global.mjs +49 -0
- package/src/lines.cjs +19 -0
- package/src/lines.mjs +17 -0
- package/src/parse/parse.cjs +44 -0
- package/src/parse/parse.mjs +42 -0
- package/src/parse/parseCell.cjs +27 -0
- package/src/parse/parseCell.mjs +25 -0
- package/src/parse/parseRow.cjs +35 -0
- package/src/parse/parseRow.mjs +32 -0
- package/src/proto/createHeaderProto.cjs +33 -0
- package/src/proto/createHeaderProto.mjs +31 -0
- package/src/proto/setPro.cjs +74 -0
- package/src/proto/setPro.mjs +72 -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,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 };
|