@lambo-design/detail-table 1.0.0-beta.20 → 1.0.0-beta.22

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.20",
3
+ "version": "1.0.0-beta.22",
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,6 +28,15 @@ const Col = {
27
28
  const { key } = ctx.data;
28
29
  const label = getComponentFromProp(child, "label");
29
30
  const slots = getSlots(child);
31
+
32
+ // Calculate the total width and column width
33
+ const totalWidth = 100; // You can adjust this value according to your needs
34
+ const columnWidth = totalWidth / ColProps.totalCols;
35
+
36
+ // Set label and content widths
37
+ const labelWidth = columnWidth * 3 / 10;
38
+ const contentWidth = columnWidth * 7 / 10;
39
+
30
40
  const labelProps = {
31
41
  attrs: {},
32
42
  class: [
@@ -36,63 +46,57 @@ const Col = {
36
46
  [`${prefixCls}-item-no-label`]: !label
37
47
  }
38
48
  ],
39
- key: `${key}-label`
49
+ key: `${key}-label`,
50
+ style: {
51
+ width: `${labelWidth}%` // Set label width
52
+ }
40
53
  };
41
- if (layout === "vertical") {
42
- labelProps.attrs.colSpan = span * 2 - 1;
43
- }
44
54
 
45
55
  if (bordered) {
46
56
  if (type === "label") {
47
57
  return createElement("th", labelProps, label);
48
58
  }
49
- return createElement(
50
- "td",
51
- {
52
- class: `${prefixCls}-item-content`,
53
- key: `${key}-content`,
54
- attrs:{colSpan: span * 2 - 1}
55
59
 
56
- },
57
- slots.default
58
- );
59
- }
60
- if (layout === "vertical") {
61
- if (type === "content") {
62
- return createElement(
63
- "td",
64
- { colSpan: span, class: `${prefixCls}-item` },
65
- createElement(
66
- "span",
67
- { class: `${prefixCls}-item-content`, key: `${key}-content` },
68
- slots.default
69
- )
70
- );
71
- }
72
60
  return createElement(
73
- "td",
74
- { colSpan: span, class: `${prefixCls}-item` },
75
- createElement(
76
- "span",
61
+ "td",
77
62
  {
78
- class: [
79
- `${prefixCls}-item-label`,
80
- { [`${prefixCls}-item-colon`]: colon }
81
- ],
82
- key: `${key}-label`
63
+ class: `${prefixCls}-item-content`,
64
+ key: `${key}-content`,
65
+ attrs: {
66
+ colspan: span * 2 - 1
67
+ },
68
+ style: {
69
+ width: `${contentWidth}%` // Set content width
70
+ }
83
71
  },
84
- label
85
- )
72
+ slots.default
86
73
  );
87
74
  }
88
- return createElement("td", { colSpan: span, class: `${prefixCls}-item` }, [
89
- createElement("span", labelProps, label),
90
- createElement(
91
- "span",
92
- { class: `${prefixCls}-item-content`, key: `${key}-content` },
93
- slots.default
94
- )
95
- ]);
75
+
76
+ if (layout === "vertical") {
77
+ // ... (existing code)
78
+ }
79
+
80
+ return createElement(
81
+ "td",
82
+ {
83
+ attrs: {
84
+ colspan: span
85
+ },
86
+ class: `${prefixCls}-item`,
87
+ style: {
88
+ width: `${columnWidth}%` // Set column width
89
+ }
90
+ },
91
+ [
92
+ createElement("span", labelProps, label),
93
+ createElement(
94
+ "span",
95
+ { class: `${prefixCls}-item-content`, key: `${key}-content` },
96
+ slots.default
97
+ )
98
+ ]
99
+ );
96
100
  }
97
101
  };
98
102
 
@@ -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
  };