@lambo-design/detail-table 1.0.0-beta.3 → 1.0.0-beta.30
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/index.js +8 -8
- package/package.json +24 -18
- package/src/components/Col.js +149 -98
- package/src/components/Row.js +73 -69
- package/src/components/props-util.js +335 -335
- package/src/components/vnode.js +147 -147
- package/src/detail-table-item.vue +23 -19
- package/src/detail-table.vue +181 -178
- package/src/styles/css/index.less +144 -143
package/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {default as LamboDetailTable} from "./src/detail-table.vue";
|
|
2
|
-
import {default as LamboDetailTableItem} from "./src/detail-table-item.vue";
|
|
3
|
-
|
|
4
|
-
export default LamboDetailTable
|
|
5
|
-
export {
|
|
6
|
-
LamboDetailTable,
|
|
7
|
-
LamboDetailTableItem
|
|
8
|
-
}
|
|
1
|
+
import {default as LamboDetailTable} from "./src/detail-table.vue";
|
|
2
|
+
import {default as LamboDetailTableItem} from "./src/detail-table-item.vue";
|
|
3
|
+
|
|
4
|
+
export default LamboDetailTable
|
|
5
|
+
export {
|
|
6
|
+
LamboDetailTable,
|
|
7
|
+
LamboDetailTableItem
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@lambo-design/detail-table",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@lambo-design/detail-table",
|
|
3
|
+
"version": "1.0.0-beta.30",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"author": "lambo",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"registry": "https://registry.npmjs.org/"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@lambo-design/shared": "^1.0.0-beta.226",
|
|
14
|
+
"@lambo-design/core": "^4.7.1-beta.147"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"release": "pnpm release-beta && git push --follow-tags && pnpm re-publish",
|
|
18
|
+
"release-major": "standard-version --release-as major",
|
|
19
|
+
"release-minor": "standard-version --release-as minor",
|
|
20
|
+
"release-patch": "standard-version --release-as patch",
|
|
21
|
+
"release-beta": "standard-version --prerelease beta",
|
|
22
|
+
"re-publish": "pnpm publish --access public --no-git-checks"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/src/components/Col.js
CHANGED
|
@@ -1,98 +1,149 @@
|
|
|
1
|
-
import { getOptionProps, getSlots, getComponentFromProp } from "./props-util";
|
|
2
|
-
|
|
3
|
-
const ColProps = {
|
|
4
|
-
child: Object,
|
|
5
|
-
bordered: Boolean,
|
|
6
|
-
colon: Boolean,
|
|
7
|
-
type: {
|
|
8
|
-
type: String,
|
|
9
|
-
validator: function(value) {
|
|
10
|
-
return ["label", "content"].indexOf(value) !== -1;
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
layout: {
|
|
14
|
-
type: String,
|
|
15
|
-
validator: function(value) {
|
|
16
|
-
return ["horizontal", "vertical"].indexOf(value) !== -1;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
import { getOptionProps, getSlots, getComponentFromProp } from "./props-util";
|
|
2
|
+
|
|
3
|
+
const ColProps = {
|
|
4
|
+
child: Object,
|
|
5
|
+
bordered: Boolean,
|
|
6
|
+
colon: Boolean,
|
|
7
|
+
type: {
|
|
8
|
+
type: String,
|
|
9
|
+
validator: function(value) {
|
|
10
|
+
return ["label", "content"].indexOf(value) !== -1;
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
layout: {
|
|
14
|
+
type: String,
|
|
15
|
+
validator: function(value) {
|
|
16
|
+
return ["horizontal", "vertical"].indexOf(value) !== -1;
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
totalCols: Number,
|
|
20
|
+
column : Number,
|
|
21
|
+
labelWidth: Number
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const Col = {
|
|
25
|
+
functional: true,
|
|
26
|
+
props: ColProps,
|
|
27
|
+
render(createElement, ctx) {
|
|
28
|
+
const { child, bordered, colon, type, layout ,column ,labelWidth} = ctx.props;
|
|
29
|
+
const { prefixCls, span = 1 } = getOptionProps(child);
|
|
30
|
+
const { key } = ctx.data;
|
|
31
|
+
const label = getComponentFromProp(child, "label");
|
|
32
|
+
const slots = getSlots(child);
|
|
33
|
+
const labelColSpan = Math.floor(labelWidth/column); // 计算 label 的长度
|
|
34
|
+
const contextColSpan = Math.floor((100-labelWidth)/column); // 计算 context 的长度
|
|
35
|
+
const promptInfo = getComponentFromProp(child, "promptInfo")
|
|
36
|
+
const labelProps = {
|
|
37
|
+
attrs: {},
|
|
38
|
+
class: [
|
|
39
|
+
`${prefixCls}-item-label`,
|
|
40
|
+
{
|
|
41
|
+
[`${prefixCls}-item-colon`]: colon,
|
|
42
|
+
[`${prefixCls}-item-no-label`]: !label
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
key: `${key}-label`,
|
|
46
|
+
style: {
|
|
47
|
+
width: `${labelColSpan}%` // 添加 label 的宽度
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
if (layout === "vertical") {
|
|
51
|
+
labelProps.attrs.colSpan = span * 2 - 1;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (bordered) {
|
|
55
|
+
if (type === "label") {
|
|
56
|
+
if (promptInfo && promptInfo !=="") {
|
|
57
|
+
let labelItem = createElement(
|
|
58
|
+
'Tooltip',
|
|
59
|
+
{
|
|
60
|
+
ref: key,
|
|
61
|
+
props: {
|
|
62
|
+
placement: 'right',
|
|
63
|
+
maxWidth: 300
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
[
|
|
67
|
+
label,
|
|
68
|
+
createElement(
|
|
69
|
+
'Icon', {
|
|
70
|
+
ref: key,
|
|
71
|
+
props: {
|
|
72
|
+
type: 'ios-information-circle-outline',
|
|
73
|
+
size: 16,
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
createElement(
|
|
78
|
+
'div', {
|
|
79
|
+
slot: 'content',
|
|
80
|
+
theme: 'light'
|
|
81
|
+
},
|
|
82
|
+
[
|
|
83
|
+
createElement('span', {},
|
|
84
|
+
promptInfo
|
|
85
|
+
)
|
|
86
|
+
]
|
|
87
|
+
)
|
|
88
|
+
]
|
|
89
|
+
)
|
|
90
|
+
return createElement('th', labelProps, [labelItem])
|
|
91
|
+
}
|
|
92
|
+
return createElement("th", labelProps, label);
|
|
93
|
+
}
|
|
94
|
+
return createElement(
|
|
95
|
+
"td",
|
|
96
|
+
{
|
|
97
|
+
class: `${prefixCls}-item-content`,
|
|
98
|
+
key: `${key}-content`,
|
|
99
|
+
attrs:{colSpan: span * 2 - 1},
|
|
100
|
+
style: {
|
|
101
|
+
width: `${contextColSpan}%` // 添加 content 的宽度
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
slots.default
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
if (layout === "vertical") {
|
|
108
|
+
if (type === "content") {
|
|
109
|
+
return createElement(
|
|
110
|
+
"td",
|
|
111
|
+
{ colSpan: span, class: `${prefixCls}-item` },
|
|
112
|
+
createElement(
|
|
113
|
+
"span",
|
|
114
|
+
{ class: `${prefixCls}-item-content`, key: `${key}-content`, style: { width: `${contextColSpan}%` } },
|
|
115
|
+
slots.default
|
|
116
|
+
)
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
return createElement(
|
|
120
|
+
"td",
|
|
121
|
+
{ colSpan: span, class: `${prefixCls}-item` },
|
|
122
|
+
createElement(
|
|
123
|
+
"span",
|
|
124
|
+
{
|
|
125
|
+
class: [
|
|
126
|
+
`${prefixCls}-item-label`,
|
|
127
|
+
{ [`${prefixCls}-item-colon`]: colon }
|
|
128
|
+
],
|
|
129
|
+
key: `${key}-label`,
|
|
130
|
+
style: {
|
|
131
|
+
width: `${labelColSpan}%` // 添加 label 的宽度
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
label
|
|
135
|
+
)
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
return createElement("td", { colSpan: span, class: `${prefixCls}-item` }, [
|
|
139
|
+
createElement("span", labelProps, label),
|
|
140
|
+
createElement(
|
|
141
|
+
"span",
|
|
142
|
+
{ class: `${prefixCls}-item-content`, key: `${key}-content`, style: { width: `${contextColSpan}%` } },
|
|
143
|
+
slots.default
|
|
144
|
+
)
|
|
145
|
+
]);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export default Col;
|
package/src/components/Row.js
CHANGED
|
@@ -1,69 +1,73 @@
|
|
|
1
|
-
import Col from "./Col";
|
|
2
|
-
|
|
3
|
-
function toArray(value) {
|
|
4
|
-
let ret = value;
|
|
5
|
-
if (value === undefined) {
|
|
6
|
-
ret = [];
|
|
7
|
-
} else if (!Array.isArray(value)) {
|
|
8
|
-
ret = [value];
|
|
9
|
-
}
|
|
10
|
-
return ret;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
functional: true,
|
|
15
|
-
render: function(createElement, context) {
|
|
16
|
-
const { children, index, prefixCls, bordered, layout, colon } = context.props;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
1
|
+
import Col from "./Col";
|
|
2
|
+
|
|
3
|
+
function toArray(value) {
|
|
4
|
+
let ret = value;
|
|
5
|
+
if (value === undefined) {
|
|
6
|
+
ret = [];
|
|
7
|
+
} else if (!Array.isArray(value)) {
|
|
8
|
+
ret = [value];
|
|
9
|
+
}
|
|
10
|
+
return ret;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
functional: true,
|
|
15
|
+
render: function(createElement, context) {
|
|
16
|
+
const { children, index, prefixCls, bordered, layout, colon,column ,labelWidth} = context.props;
|
|
17
|
+
const totalCols = toArray(children).length;
|
|
18
|
+
const renderCol = (colItem, type, idx) => {
|
|
19
|
+
const colProps = {
|
|
20
|
+
child: colItem,
|
|
21
|
+
bordered: bordered,
|
|
22
|
+
colon: colon,
|
|
23
|
+
type: type,
|
|
24
|
+
layout: layout,
|
|
25
|
+
totalCols: totalCols,
|
|
26
|
+
column :column,
|
|
27
|
+
labelWidth:labelWidth
|
|
28
|
+
}
|
|
29
|
+
return createElement(Col, {props:colProps,key: `${type}-${colItem.key || idx}`});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const cloneChildren = [];
|
|
33
|
+
const cloneContentChildren = [];
|
|
34
|
+
toArray(children).forEach((childrenItem, idx) => {
|
|
35
|
+
cloneChildren.push(renderCol(childrenItem, "label", idx));
|
|
36
|
+
if (layout === "vertical") {
|
|
37
|
+
cloneContentChildren.push(renderCol(childrenItem, "content", idx));
|
|
38
|
+
} else if (bordered) {
|
|
39
|
+
cloneChildren.push(renderCol(childrenItem, "content", idx));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (layout === "vertical") {
|
|
44
|
+
return [
|
|
45
|
+
createElement(
|
|
46
|
+
'tr',
|
|
47
|
+
{
|
|
48
|
+
class: `${prefixCls}-row`,
|
|
49
|
+
key: `label-${index}`
|
|
50
|
+
},
|
|
51
|
+
cloneChildren
|
|
52
|
+
),
|
|
53
|
+
createElement(
|
|
54
|
+
'tr',
|
|
55
|
+
{
|
|
56
|
+
class: `${prefixCls}-row`,
|
|
57
|
+
key: `content-${index}`
|
|
58
|
+
},
|
|
59
|
+
cloneContentChildren
|
|
60
|
+
)
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return createElement(
|
|
65
|
+
'tr',
|
|
66
|
+
{
|
|
67
|
+
class: `${prefixCls}-row`,
|
|
68
|
+
key: index
|
|
69
|
+
},
|
|
70
|
+
cloneChildren
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
};
|