@lambo-design/detail-table 1.0.0-beta.30 → 1.0.0-beta.31

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.
@@ -1,181 +1,180 @@
1
- <template>
2
- <div
3
- :class="[
4
- prefixCls,
5
- {
6
- [`${prefixCls}-${size}`]: size !== 'default',
7
- [`${prefixCls}-bordered`]: !!bordered,
8
- },
9
- ]"
10
- >
11
- <div :class="[`${prefixCls}-view`]">
12
- <table>
13
- <tbody>
14
- <Row
15
- v-for="(item, index) in childrenArray"
16
- :children="item"
17
- :key="index"
18
- :index="index"
19
- :prefixCls="prefixCls"
20
- :bordered="bordered"
21
- :layout="layout"
22
- :colon="colon"
23
- :column="column"
24
- :labelWidth="labelWidth"
25
- >
26
- </Row>
27
- </tbody>
28
- </table>
29
- </div>
30
- </div>
31
- </template>
32
- <script>
33
- import {
34
- isValidElement,
35
- getOptionProps,
36
- } from "./components/props-util";
37
- import { cloneElement } from "./components/vnode";
38
- import Row from "./components/Row";
39
- const defaultColumnMap = {
40
- xxl: 3,
41
- xl: 3,
42
- lg: 3,
43
- md: 3,
44
- sm: 2,
45
- xs: 1,
46
- };
47
- function toArray(value) {
48
- let ret = value;
49
- if (value === undefined) {
50
- ret = [];
51
- } else if (!Array.isArray(value)) {
52
- ret = [value];
53
- }
54
- return ret;
55
- }
56
- export default {
57
- name: "LamboDetailTable",
58
- components: { Row },
59
- props: {
60
- prefixCls: {
61
- type: String,
62
- default: "lambo-detail-table",
63
- },
64
- bordered: Boolean,
65
- size: {
66
- type: String,
67
- default: "default",
68
- validator: function (value) {
69
- return ["default", "middle", "small"].indexOf(value) !== -1;
70
- },
71
- },
72
- column: Number,
73
- labelWidth:Number,
74
- layout: {
75
- type: String,
76
- default: "horizontal",
77
- validator: function (value) {
78
- return ["horizontal", "vertical"].indexOf(value) !== -1;
79
- },
80
- },
81
- colon: Boolean,
82
- },
83
- data() {
84
- return {
85
- screens: {},
86
- token: undefined,
87
- childrenArray:null
88
- };
89
- },
90
- computed: {
91
- /*childrenArray: function () {
92
- return this.refreshTable();
93
- },*/
94
- },
95
- methods: {
96
- refreshTable(){
97
- this.childrenArray = null;
98
- const { prefixCls } = this;
99
- const children = this.$slots.default;
100
- const cloneChildren = toArray(children)
101
- .map((child) => {
102
- if (isValidElement(child)) {
103
- return cloneElement(child, {
104
- props: {
105
- prefixCls,
106
- },
107
- });
108
- }
109
- return null;
110
- })
111
- .filter((node) => node);
112
- const column = this.getColumn();
113
- this.childrenArray = this.generateChildrenRows(cloneChildren, column);
114
- console.log('array:',this.childrenArray)
115
- },
116
- getColumn() {
117
- const { column } = this.$props;
118
- // if (typeof column === "object") {
119
- // for (let i = 0; i < responsiveArray.length; i++) {
120
- // const breakpoint = responsiveArray[i];
121
- // if (this.screens[breakpoint] && column[breakpoint] !== undefined) {
122
- // return column[breakpoint] || defaultColumnMap[breakpoint];
123
- // }
124
- // }
125
- // }
126
- // If the configuration is not an object, it is a number, return number
127
- if (typeof column === "number") {
128
- return column;
129
- }
130
- // If it is an object, but no response is found, this happens only in the test.
131
- // Maybe there are some strange environments
132
- return 3;
133
- },
134
- generateChildrenRows(children, column) {
135
- const rows = [];
136
- let columns = null;
137
- let leftSpans;
138
-
139
- const itemNodes = toArray(children);
140
- itemNodes.forEach((node, index) => {
141
- const itemProps = getOptionProps(node);
142
- let itemNode = node;
143
-
144
- if (!columns) {
145
- leftSpans = column;
146
- columns = [];
147
- rows.push(columns);
148
- }
149
-
150
- // Always set last span to align the end of Descriptions
151
- const lastItem = index === itemNodes.length - 1;
152
- let lastSpanSame = true;
153
- if (lastItem) {
154
- lastSpanSame = !itemProps.span || itemProps.span === leftSpans;
155
- itemNode = cloneElement(itemNode, {
156
- props: {
157
- span: leftSpans,
158
- },
159
- });
160
- }
161
-
162
- // Calculate left fill span
163
- const { span = 1 } = itemProps;
164
- columns.push(itemNode);
165
- leftSpans -= span;
166
-
167
- if (leftSpans <= 0) {
168
- columns = null;
169
- }
170
- });
171
- return rows;
172
- },
173
- },
174
- mounted() {
175
- this.refreshTable();
176
- }
177
- };
178
- </script>
179
- <style lang="less" scoped>
180
- @import "styles/css/index";
181
- </style>
1
+ <template>
2
+ <div
3
+ :class="[
4
+ prefixCls,
5
+ {
6
+ [`${prefixCls}-${size}`]: size !== 'default',
7
+ [`${prefixCls}-bordered`]: !!bordered,
8
+ },
9
+ ]"
10
+ >
11
+ <div :class="[`${prefixCls}-view`]">
12
+ <table>
13
+ <tbody>
14
+ <Row
15
+ v-for="(item, index) in childrenArray"
16
+ :children="item"
17
+ :key="index"
18
+ :index="index"
19
+ :prefixCls="prefixCls"
20
+ :bordered="bordered"
21
+ :layout="layout"
22
+ :colon="colon"
23
+ :column="column"
24
+ :labelWidth="labelWidth"
25
+ >
26
+ </Row>
27
+ </tbody>
28
+ </table>
29
+ </div>
30
+ </div>
31
+ </template>
32
+ <script>
33
+ import {
34
+ isValidElement,
35
+ getOptionProps,
36
+ } from "./components/props-util";
37
+ import { cloneElement } from "./components/vnode";
38
+ import Row from "./components/Row";
39
+ const defaultColumnMap = {
40
+ xxl: 3,
41
+ xl: 3,
42
+ lg: 3,
43
+ md: 3,
44
+ sm: 2,
45
+ xs: 1,
46
+ };
47
+ function toArray(value) {
48
+ let ret = value;
49
+ if (value === undefined) {
50
+ ret = [];
51
+ } else if (!Array.isArray(value)) {
52
+ ret = [value];
53
+ }
54
+ return ret;
55
+ }
56
+ export default {
57
+ name: "LamboDetailTable",
58
+ components: { Row },
59
+ props: {
60
+ prefixCls: {
61
+ type: String,
62
+ default: "lambo-detail-table",
63
+ },
64
+ bordered: Boolean,
65
+ size: {
66
+ type: String,
67
+ default: "default",
68
+ validator: function (value) {
69
+ return ["default", "middle", "small"].indexOf(value) !== -1;
70
+ },
71
+ },
72
+ column: Number,
73
+ labelWidth:Number,
74
+ layout: {
75
+ type: String,
76
+ default: "horizontal",
77
+ validator: function (value) {
78
+ return ["horizontal", "vertical"].indexOf(value) !== -1;
79
+ },
80
+ },
81
+ colon: Boolean,
82
+ },
83
+ data() {
84
+ return {
85
+ screens: {},
86
+ token: undefined,
87
+ childrenArray:null
88
+ };
89
+ },
90
+ computed: {
91
+ /*childrenArray: function () {
92
+ return this.refreshTable();
93
+ },*/
94
+ },
95
+ methods: {
96
+ refreshTable(){
97
+ this.childrenArray = null;
98
+ const { prefixCls } = this;
99
+ const children = this.$slots.default;
100
+ const cloneChildren = toArray(children)
101
+ .map((child) => {
102
+ if (isValidElement(child)) {
103
+ return cloneElement(child, {
104
+ props: {
105
+ prefixCls,
106
+ },
107
+ });
108
+ }
109
+ return null;
110
+ })
111
+ .filter((node) => node);
112
+ const column = this.getColumn();
113
+ this.childrenArray = this.generateChildrenRows(cloneChildren, column);
114
+ },
115
+ getColumn() {
116
+ const { column } = this.$props;
117
+ // if (typeof column === "object") {
118
+ // for (let i = 0; i < responsiveArray.length; i++) {
119
+ // const breakpoint = responsiveArray[i];
120
+ // if (this.screens[breakpoint] && column[breakpoint] !== undefined) {
121
+ // return column[breakpoint] || defaultColumnMap[breakpoint];
122
+ // }
123
+ // }
124
+ // }
125
+ // If the configuration is not an object, it is a number, return number
126
+ if (typeof column === "number") {
127
+ return column;
128
+ }
129
+ // If it is an object, but no response is found, this happens only in the test.
130
+ // Maybe there are some strange environments
131
+ return 3;
132
+ },
133
+ generateChildrenRows(children, column) {
134
+ const rows = [];
135
+ let columns = null;
136
+ let leftSpans;
137
+
138
+ const itemNodes = toArray(children);
139
+ itemNodes.forEach((node, index) => {
140
+ const itemProps = getOptionProps(node);
141
+ let itemNode = node;
142
+
143
+ if (!columns) {
144
+ leftSpans = column;
145
+ columns = [];
146
+ rows.push(columns);
147
+ }
148
+
149
+ // Always set last span to align the end of Descriptions
150
+ const lastItem = index === itemNodes.length - 1;
151
+ let lastSpanSame = true;
152
+ if (lastItem) {
153
+ lastSpanSame = !itemProps.span || itemProps.span === leftSpans;
154
+ itemNode = cloneElement(itemNode, {
155
+ props: {
156
+ span: leftSpans,
157
+ },
158
+ });
159
+ }
160
+
161
+ // Calculate left fill span
162
+ const { span = 1 } = itemProps;
163
+ columns.push(itemNode);
164
+ leftSpans -= span;
165
+
166
+ if (leftSpans <= 0) {
167
+ columns = null;
168
+ }
169
+ });
170
+ return rows;
171
+ },
172
+ },
173
+ mounted() {
174
+ this.refreshTable();
175
+ }
176
+ };
177
+ </script>
178
+ <style lang="less" scoped>
179
+ @import "styles/css/index";
180
+ </style>
@@ -1,144 +1,144 @@
1
- @import "@lambo-design/core/src/styles/default.less";
2
- @descriptions-prefix-cls: lambo-detail-table;
3
-
4
- @descriptions-default-padding: 10px 16px;
5
- @descriptions-middle-padding: 8px 12px;
6
- @descriptions-small-padding: 6px 8px;
7
-
8
- .@{descriptions-prefix-cls} {
9
- &-title {
10
- margin-bottom: 20px;
11
- color: fade(#000, 85%);
12
- font-weight: bold;
13
- font-size: 16px;
14
- line-height: 1.5;
15
- }
16
-
17
- &-view {
18
- width: 100%;
19
- overflow: hidden;
20
- table {
21
- width: 100%;
22
- table-layout: fixed;
23
- border-collapse: collapse
24
- }
25
- }
26
-
27
- &-row {
28
- > th,
29
- > td {
30
- padding-bottom: 16px;
31
- }
32
- &:last-child {
33
- border-bottom: none;
34
- }
35
- }
36
-
37
- &-item-label {
38
- color: var(--form-item-label-text-color,@_form-item-label-text-color);
39
- text-align: left;
40
- font-weight: 500;
41
- font-size: 14px;
42
- line-height: 1.5;
43
- width: 11%;
44
-
45
- &::after {
46
- position: relative;
47
- top: -0.5px;
48
- margin: 0 8px 0 2px;
49
- content: ' ';
50
- }
51
- }
52
-
53
- &-item-colon {
54
- &::after {
55
- content: ':';
56
- }
57
- }
58
-
59
- &-item-no-label {
60
- &::after {
61
- margin: 0;
62
- content: '';
63
- }
64
- }
65
-
66
- &-item-content {
67
- display: table-cell;
68
- color: var(--text-color,@_text-color);
69
- font-size: 14px;
70
- line-height: 1.5;
71
- width: 22%;
72
- }
73
-
74
- &-item {
75
- padding-bottom: 0;
76
- > span {
77
- display: inline-block;
78
- }
79
- }
80
-
81
- &-middle {
82
- .@{descriptions-prefix-cls}-row {
83
- > th,
84
- > td {
85
- padding-bottom: 12px;
86
- }
87
- }
88
- }
89
-
90
- &-small {
91
- .@{descriptions-prefix-cls}-row {
92
- > th,
93
- > td {
94
- padding-bottom: 8px;
95
- }
96
- }
97
- }
98
-
99
- &-bordered {
100
- .@{descriptions-prefix-cls}-view {
101
- > table {
102
- table-layout: auto;
103
- }
104
- }
105
-
106
- .@{descriptions-prefix-cls}-item-label,
107
- .@{descriptions-prefix-cls}-item-content {
108
- padding: @descriptions-default-padding;
109
- border: 1px solid var(--border-color-base,@_border-color-base);
110
- background-color: var(--form-item-detail-bg-color,@_form-item-detail-bg-color);
111
- &:last-child {
112
- border-right: none;
113
- }
114
- }
115
-
116
- .@{descriptions-prefix-cls}-item-label {
117
- //background-color: #f0f0f1ff;
118
- background-color: var(--table-thead-bg,@_table-thead-bg);
119
-
120
- &::after {
121
- display: none;
122
- }
123
- }
124
-
125
- .@{descriptions-prefix-cls}-row {
126
- border: 1px solid var(--border-color-base,@_border-color-base); ;
127
- }
128
-
129
- &.@{descriptions-prefix-cls}-middle {
130
- .@{descriptions-prefix-cls}-item-label,
131
- .@{descriptions-prefix-cls}-item-content {
132
- padding: @descriptions-middle-padding;
133
- }
134
- }
135
-
136
- &.@{descriptions-prefix-cls}-small {
137
- .@{descriptions-prefix-cls}-item-label,
138
- .@{descriptions-prefix-cls}-item-content {
139
- padding: @descriptions-small-padding;
140
- }
141
- }
142
- }
143
- }
144
-
1
+ @import "@lambo-design/core/src/styles/default.less";
2
+ @descriptions-prefix-cls: lambo-detail-table;
3
+
4
+ @descriptions-default-padding: 10px 16px;
5
+ @descriptions-middle-padding: 8px 12px;
6
+ @descriptions-small-padding: 6px 8px;
7
+
8
+ .@{descriptions-prefix-cls} {
9
+ &-title {
10
+ margin-bottom: 20px;
11
+ color: fade(#000, 85%);
12
+ font-weight: bold;
13
+ font-size: 16px;
14
+ line-height: 1.5;
15
+ }
16
+
17
+ &-view {
18
+ width: 100%;
19
+ overflow: hidden;
20
+ table {
21
+ width: 100%;
22
+ table-layout: fixed;
23
+ border-collapse: collapse
24
+ }
25
+ }
26
+
27
+ &-row {
28
+ > th,
29
+ > td {
30
+ padding-bottom: 16px;
31
+ }
32
+ &:last-child {
33
+ border-bottom: none;
34
+ }
35
+ }
36
+
37
+ &-item-label {
38
+ color: var(--form-item-label-text-color,@_form-item-label-text-color);
39
+ text-align: left;
40
+ font-weight: 500;
41
+ font-size: 14px;
42
+ line-height: 1.5;
43
+ width: 11%;
44
+
45
+ &::after {
46
+ position: relative;
47
+ top: -0.5px;
48
+ margin: 0 8px 0 2px;
49
+ content: ' ';
50
+ }
51
+ }
52
+
53
+ &-item-colon {
54
+ &::after {
55
+ content: ':';
56
+ }
57
+ }
58
+
59
+ &-item-no-label {
60
+ &::after {
61
+ margin: 0;
62
+ content: '';
63
+ }
64
+ }
65
+
66
+ &-item-content {
67
+ display: table-cell;
68
+ color: var(--text-color,@_text-color);
69
+ font-size: 14px;
70
+ line-height: 1.5;
71
+ width: 22%;
72
+ }
73
+
74
+ &-item {
75
+ padding-bottom: 0;
76
+ > span {
77
+ display: inline-block;
78
+ }
79
+ }
80
+
81
+ &-middle {
82
+ .@{descriptions-prefix-cls}-row {
83
+ > th,
84
+ > td {
85
+ padding-bottom: 12px;
86
+ }
87
+ }
88
+ }
89
+
90
+ &-small {
91
+ .@{descriptions-prefix-cls}-row {
92
+ > th,
93
+ > td {
94
+ padding-bottom: 8px;
95
+ }
96
+ }
97
+ }
98
+
99
+ &-bordered {
100
+ .@{descriptions-prefix-cls}-view {
101
+ > table {
102
+ table-layout: auto;
103
+ }
104
+ }
105
+
106
+ .@{descriptions-prefix-cls}-item-label,
107
+ .@{descriptions-prefix-cls}-item-content {
108
+ padding: @descriptions-default-padding;
109
+ border: 1px solid var(--border-color-base,@_border-color-base);
110
+ background-color: var(--form-item-detail-bg-color,@_form-item-detail-bg-color);
111
+ &:last-child {
112
+ border-right: none;
113
+ }
114
+ }
115
+
116
+ .@{descriptions-prefix-cls}-item-label {
117
+ //background-color: #f0f0f1ff;
118
+ background-color: var(--table-thead-bg,@_table-thead-bg);
119
+
120
+ &::after {
121
+ display: none;
122
+ }
123
+ }
124
+
125
+ .@{descriptions-prefix-cls}-row {
126
+ border: 1px solid var(--border-color-base,@_border-color-base); ;
127
+ }
128
+
129
+ &.@{descriptions-prefix-cls}-middle {
130
+ .@{descriptions-prefix-cls}-item-label,
131
+ .@{descriptions-prefix-cls}-item-content {
132
+ padding: @descriptions-middle-padding;
133
+ }
134
+ }
135
+
136
+ &.@{descriptions-prefix-cls}-small {
137
+ .@{descriptions-prefix-cls}-item-label,
138
+ .@{descriptions-prefix-cls}-item-content {
139
+ padding: @descriptions-small-padding;
140
+ }
141
+ }
142
+ }
143
+ }
144
+