@lambo-design/detail-table 1.0.0-beta.21 → 1.0.0-beta.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design/detail-table",
3
- "version": "1.0.0-beta.21",
3
+ "version": "1.0.0-beta.23",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -10,8 +10,8 @@
10
10
  "registry": "https://registry.npmjs.org/"
11
11
  },
12
12
  "devDependencies": {
13
- "@lambo-design/core": "^4.7.1-beta.60",
14
- "@lambo-design/shared": "^1.0.0-beta.43"
13
+ "@lambo-design/shared": "^1.0.0-beta.43",
14
+ "@lambo-design/core": "^4.7.1-beta.60"
15
15
  },
16
16
  "scripts": {}
17
17
  }
@@ -15,7 +15,8 @@ const ColProps = {
15
15
  validator: function(value) {
16
16
  return ["horizontal", "vertical"].indexOf(value) !== -1;
17
17
  }
18
- }
18
+ },
19
+ totalCols: Number
19
20
  };
20
21
 
21
22
  const Col = {
@@ -27,15 +28,8 @@ const Col = {
27
28
  const { key } = ctx.data;
28
29
  const label = getComponentFromProp(child, "label");
29
30
  const slots = getSlots(child);
30
-
31
- // Calculate the total width and column width
32
- const totalWidth = 100; // You can adjust this value according to your needs
33
- const columnWidth = totalWidth / 6;
34
-
35
- // Set label and content widths
36
- const labelWidth = columnWidth;
37
- const contentWidth = columnWidth * 2;
38
-
31
+ const labelColSpan = Math.floor(100 / ColProps.totalCols * 0.3); // 计算 label 的长度
32
+ const contextColSpan = Math.floor(100 / ColProps.totalCols * 0.7); // 计算 context 的长度
39
33
  const labelProps = {
40
34
  attrs: {},
41
35
  class: [
@@ -47,55 +41,69 @@ const Col = {
47
41
  ],
48
42
  key: `${key}-label`,
49
43
  style: {
50
- width: `${labelWidth}%` // Set label width
44
+ width: `${labelColSpan}%` // 添加 label 的宽度
51
45
  }
52
46
  };
47
+ if (layout === "vertical") {
48
+ labelProps.attrs.colSpan = span * 2 - 1;
49
+ }
53
50
 
54
51
  if (bordered) {
55
52
  if (type === "label") {
56
53
  return createElement("th", labelProps, label);
57
54
  }
58
-
59
55
  return createElement(
60
56
  "td",
61
57
  {
62
58
  class: `${prefixCls}-item-content`,
63
59
  key: `${key}-content`,
64
- attrs: {
65
- colspan: span * 2 - 1
66
- },
60
+ attrs:{colSpan: span * 2 - 1},
67
61
  style: {
68
- width: `${contentWidth}%` // Set content width
62
+ width: `${contextColSpan}%` // 添加 content 的宽度
69
63
  }
70
64
  },
71
65
  slots.default
72
66
  );
73
67
  }
74
-
75
68
  if (layout === "vertical") {
76
- // ... (existing code)
77
- }
78
-
79
- return createElement(
80
- "td",
81
- {
82
- attrs: {
83
- colspan: span
84
- },
85
- class: `${prefixCls}-item`,
86
- style: {
87
- width: `${columnWidth}%` // Set column width
88
- }
89
- },
90
- [
91
- createElement("span", labelProps, label),
69
+ if (type === "content") {
70
+ return createElement(
71
+ "td",
72
+ { colSpan: span, class: `${prefixCls}-item` },
73
+ createElement(
74
+ "span",
75
+ { class: `${prefixCls}-item-content`, key: `${key}-content`, style: { width: `${contextColSpan}%` } },
76
+ slots.default
77
+ )
78
+ );
79
+ }
80
+ return createElement(
81
+ "td",
82
+ { colSpan: span, class: `${prefixCls}-item` },
92
83
  createElement(
93
84
  "span",
94
- { class: `${prefixCls}-item-content`, key: `${key}-content` },
95
- slots.default
85
+ {
86
+ class: [
87
+ `${prefixCls}-item-label`,
88
+ { [`${prefixCls}-item-colon`]: colon }
89
+ ],
90
+ key: `${key}-label`,
91
+ style: {
92
+ width: `${labelColSpan}%` // 添加 label 的宽度
93
+ }
94
+ },
95
+ label
96
96
  )
97
- ]
98
- );
97
+ );
98
+ }
99
+ return createElement("td", { colSpan: span, class: `${prefixCls}-item` }, [
100
+ createElement("span", labelProps, label),
101
+ createElement(
102
+ "span",
103
+ { class: `${prefixCls}-item-content`, key: `${key}-content`, style: { width: `${contextColSpan}%` } },
104
+ slots.default
105
+ )
106
+ ]);
99
107
  }
100
108
  };
101
109
 
@@ -14,13 +14,15 @@ export default {
14
14
  functional: true,
15
15
  render: function(createElement, context) {
16
16
  const { children, index, prefixCls, bordered, layout, colon } = context.props;
17
+ const totalCols = toArray(children).length;
17
18
  const renderCol = (colItem, type, idx) => {
18
19
  const colProps = {
19
20
  child: colItem,
20
21
  bordered: bordered,
21
22
  colon: colon,
22
23
  type: type,
23
- layout: layout
24
+ layout: layout,
25
+ totalCols: totalCols,
24
26
  }
25
27
  return createElement(Col, {props:colProps,key: `${type}-${colItem.key || idx}`});
26
28
  };
@@ -40,6 +40,7 @@
40
40
  font-weight: 500;
41
41
  font-size: 14px;
42
42
  line-height: 1.5;
43
+ width: 11%;
43
44
 
44
45
  &::after {
45
46
  position: relative;
@@ -67,6 +68,7 @@
67
68
  color: var(--text-color,@_text-color);;
68
69
  font-size: 14px;
69
70
  line-height: 1.5;
71
+ width: 22%;
70
72
  }
71
73
 
72
74
  &-item {