@laozei/element-ui 2.16.0 → 2.16.2
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/lib/element-ui.common.js +52 -22
- package/lib/index.js +1 -1
- package/lib/table.js +54 -24
- package/lib/utils/util.js +7 -0
- package/package.json +3 -3
- package/packages/table/src/table-footer.js +54 -23
- package/src/index.js +1 -1
- package/src/utils/util.js +4 -0
package/lib/table.js
CHANGED
|
@@ -647,7 +647,7 @@ module.exports = require("normalize-wheel");
|
|
|
647
647
|
__webpack_require__.r(__webpack_exports__);
|
|
648
648
|
|
|
649
649
|
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/table/src/table.vue?vue&type=template&id=493fe34e&
|
|
650
|
-
var
|
|
650
|
+
var tablevue_type_template_id_493fe34e_render = function() {
|
|
651
651
|
var _vm = this
|
|
652
652
|
var _h = _vm.$createElement
|
|
653
653
|
var _c = _vm._self._c || _h
|
|
@@ -1083,7 +1083,7 @@ var render = function() {
|
|
|
1083
1083
|
)
|
|
1084
1084
|
}
|
|
1085
1085
|
var staticRenderFns = []
|
|
1086
|
-
|
|
1086
|
+
tablevue_type_template_id_493fe34e_render._withStripped = true
|
|
1087
1087
|
|
|
1088
1088
|
|
|
1089
1089
|
// CONCATENATED MODULE: ./packages/table/src/table.vue?vue&type=template&id=493fe34e&
|
|
@@ -4076,11 +4076,14 @@ var convertToRows = function convertToRows(originColumns) {
|
|
|
4076
4076
|
}
|
|
4077
4077
|
});
|
|
4078
4078
|
// CONCATENATED MODULE: ./packages/table/src/table-footer.js
|
|
4079
|
+
var table_footer_typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
4080
|
+
|
|
4079
4081
|
var table_footer_extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
4080
4082
|
|
|
4081
4083
|
|
|
4082
4084
|
|
|
4083
4085
|
|
|
4086
|
+
|
|
4084
4087
|
/* harmony default export */ var table_footer = ({
|
|
4085
4088
|
name: 'ElTableFooter',
|
|
4086
4089
|
|
|
@@ -4089,13 +4092,14 @@ var table_footer_extends = Object.assign || function (target) { for (var i = 1;
|
|
|
4089
4092
|
render: function render(h) {
|
|
4090
4093
|
var _this = this;
|
|
4091
4094
|
|
|
4092
|
-
var
|
|
4095
|
+
var rows = [];
|
|
4096
|
+
|
|
4093
4097
|
if (this.summaryMethod) {
|
|
4094
|
-
|
|
4098
|
+
rows = this.summaryMethod({ columns: this.columns, data: this.store.states.data });
|
|
4095
4099
|
} else {
|
|
4096
4100
|
this.columns.forEach(function (column, index) {
|
|
4097
4101
|
if (index === 0) {
|
|
4098
|
-
|
|
4102
|
+
rows[index] = _this.sumText;
|
|
4099
4103
|
return;
|
|
4100
4104
|
}
|
|
4101
4105
|
var values = _this.store.states.data.map(function (item) {
|
|
@@ -4112,7 +4116,7 @@ var table_footer_extends = Object.assign || function (target) { for (var i = 1;
|
|
|
4112
4116
|
});
|
|
4113
4117
|
var precision = Math.max.apply(null, precisions);
|
|
4114
4118
|
if (!notNumber) {
|
|
4115
|
-
|
|
4119
|
+
rows[index] = values.reduce(function (prev, curr) {
|
|
4116
4120
|
var value = Number(curr);
|
|
4117
4121
|
if (!isNaN(value)) {
|
|
4118
4122
|
return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
|
|
@@ -4121,11 +4125,15 @@ var table_footer_extends = Object.assign || function (target) { for (var i = 1;
|
|
|
4121
4125
|
}
|
|
4122
4126
|
}, 0);
|
|
4123
4127
|
} else {
|
|
4124
|
-
|
|
4128
|
+
rows[index] = '';
|
|
4125
4129
|
}
|
|
4126
4130
|
});
|
|
4127
4131
|
}
|
|
4128
4132
|
|
|
4133
|
+
if (Object(util_["isUnidimensionalArray"])(rows)) {
|
|
4134
|
+
rows = [rows];
|
|
4135
|
+
}
|
|
4136
|
+
|
|
4129
4137
|
return h(
|
|
4130
4138
|
'table',
|
|
4131
4139
|
{
|
|
@@ -4143,22 +4151,28 @@ var table_footer_extends = Object.assign || function (target) { for (var i = 1;
|
|
|
4143
4151
|
}) : '']), h(
|
|
4144
4152
|
'tbody',
|
|
4145
4153
|
{ 'class': [{ 'has-gutter': this.hasGutter }] },
|
|
4146
|
-
[
|
|
4147
|
-
return h(
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4154
|
+
[rows.map(function (row, $index) {
|
|
4155
|
+
return h('tr', [_this.columns.map(function (column, cellIndex) {
|
|
4156
|
+
var _getSpan = _this.getSpan(row, column, $index, cellIndex),
|
|
4157
|
+
rowspan = _getSpan.rowspan,
|
|
4158
|
+
colspan = _getSpan.colspan;
|
|
4159
|
+
|
|
4160
|
+
return h(
|
|
4161
|
+
'td',
|
|
4162
|
+
{
|
|
4163
|
+
key: cellIndex,
|
|
4164
|
+
attrs: { rowspan: rowspan,
|
|
4165
|
+
colspan: colspan
|
|
4166
|
+
},
|
|
4167
|
+
'class': [].concat(_this.getRowClasses(column, cellIndex), ['el-table__cell']) },
|
|
4168
|
+
[h(
|
|
4169
|
+
'div',
|
|
4170
|
+
{ 'class': ['cell', column.labelClassName] },
|
|
4171
|
+
[row[cellIndex]]
|
|
4172
|
+
)]
|
|
4173
|
+
);
|
|
4174
|
+
}), _this.hasGutter ? h('th', { 'class': 'el-table__cell gutter' }) : '']);
|
|
4175
|
+
})]
|
|
4162
4176
|
)]
|
|
4163
4177
|
);
|
|
4164
4178
|
},
|
|
@@ -4235,6 +4249,22 @@ var table_footer_extends = Object.assign || function (target) { for (var i = 1;
|
|
|
4235
4249
|
classes.push('is-leaf');
|
|
4236
4250
|
}
|
|
4237
4251
|
return classes;
|
|
4252
|
+
},
|
|
4253
|
+
getSpan: function getSpan(row, column, rowIndex, columnIndex) {
|
|
4254
|
+
var rowspan = 1;
|
|
4255
|
+
var colspan = 1;
|
|
4256
|
+
var fn = this.table.spanMethod;
|
|
4257
|
+
if (typeof fn === 'function') {
|
|
4258
|
+
var result = fn({ row: row, column: column, rowIndex: rowIndex, columnIndex: columnIndex });
|
|
4259
|
+
if (Array.isArray(result)) {
|
|
4260
|
+
rowspan = result[0];
|
|
4261
|
+
colspan = result[1];
|
|
4262
|
+
} else if ((typeof result === 'undefined' ? 'undefined' : table_footer_typeof(result)) === 'object') {
|
|
4263
|
+
rowspan = result.rowspan;
|
|
4264
|
+
colspan = result.colspan;
|
|
4265
|
+
}
|
|
4266
|
+
}
|
|
4267
|
+
return { rowspan: rowspan, colspan: colspan };
|
|
4238
4268
|
}
|
|
4239
4269
|
}
|
|
4240
4270
|
});
|
|
@@ -4969,7 +4999,7 @@ var tableIdSeed = 1;
|
|
|
4969
4999
|
|
|
4970
5000
|
var table_component = Object(componentNormalizer["a" /* default */])(
|
|
4971
5001
|
src_tablevue_type_script_lang_js_,
|
|
4972
|
-
|
|
5002
|
+
tablevue_type_template_id_493fe34e_render,
|
|
4973
5003
|
staticRenderFns,
|
|
4974
5004
|
false,
|
|
4975
5005
|
null,
|
package/lib/utils/util.js
CHANGED
|
@@ -12,6 +12,7 @@ exports.getPropByPath = getPropByPath;
|
|
|
12
12
|
exports.rafThrottle = rafThrottle;
|
|
13
13
|
exports.objToArray = objToArray;
|
|
14
14
|
exports.getExternalScalingRatio = getExternalScalingRatio;
|
|
15
|
+
exports.isUnidimensionalArray = isUnidimensionalArray;
|
|
15
16
|
|
|
16
17
|
var _vue = require('vue');
|
|
17
18
|
|
|
@@ -287,4 +288,10 @@ function getExternalScalingRatio(el) {
|
|
|
287
288
|
|
|
288
289
|
var scaleMatch = transform.match(/scale\(([^)]+)\)/);
|
|
289
290
|
return scaleMatch ? Number(scaleMatch[1]) : 1;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function isUnidimensionalArray(arr) {
|
|
294
|
+
return Array.isArray(arr) && !arr.every(function (item) {
|
|
295
|
+
return Array.isArray(item);
|
|
296
|
+
});
|
|
290
297
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laozei/element-ui",
|
|
3
|
-
"version": "2.16.
|
|
3
|
+
"version": "2.16.2",
|
|
4
4
|
"description": "A Component Library for Vue.js.",
|
|
5
5
|
"main": "lib/element-ui.common.js",
|
|
6
6
|
"files": [
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
],
|
|
47
47
|
"repository": {
|
|
48
48
|
"type": "git",
|
|
49
|
-
"url": "git@github.com:
|
|
49
|
+
"url": "git@github.com:laozei6401/element.git"
|
|
50
50
|
},
|
|
51
51
|
"homepage": "http://element.eleme.io",
|
|
52
52
|
"keywords": [
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
],
|
|
57
57
|
"license": "MIT",
|
|
58
58
|
"bugs": {
|
|
59
|
-
"url": "https://github.com/
|
|
59
|
+
"url": "https://github.com/laozei6401/element/issues"
|
|
60
60
|
},
|
|
61
61
|
"unpkg": "lib/index.js",
|
|
62
62
|
"style": "lib/theme-chalk/index.css",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isUnidimensionalArray } from 'element-ui/src/utils/util';
|
|
1
2
|
import LayoutObserver from './layout-observer';
|
|
2
3
|
import { mapStates } from './store/helper';
|
|
3
4
|
|
|
@@ -7,13 +8,14 @@ export default {
|
|
|
7
8
|
mixins: [LayoutObserver],
|
|
8
9
|
|
|
9
10
|
render(h) {
|
|
10
|
-
let
|
|
11
|
+
let rows = [];
|
|
12
|
+
|
|
11
13
|
if (this.summaryMethod) {
|
|
12
|
-
|
|
14
|
+
rows = this.summaryMethod({ columns: this.columns, data: this.store.states.data });
|
|
13
15
|
} else {
|
|
14
16
|
this.columns.forEach((column, index) => {
|
|
15
17
|
if (index === 0) {
|
|
16
|
-
|
|
18
|
+
rows[index] = this.sumText;
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
21
|
const values = this.store.states.data.map(item => Number(item[column.property]));
|
|
@@ -28,7 +30,7 @@ export default {
|
|
|
28
30
|
});
|
|
29
31
|
const precision = Math.max.apply(null, precisions);
|
|
30
32
|
if (!notNumber) {
|
|
31
|
-
|
|
33
|
+
rows[index] = values.reduce((prev, curr) => {
|
|
32
34
|
const value = Number(curr);
|
|
33
35
|
if (!isNaN(value)) {
|
|
34
36
|
return parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
|
|
@@ -37,11 +39,15 @@ export default {
|
|
|
37
39
|
}
|
|
38
40
|
}, 0);
|
|
39
41
|
} else {
|
|
40
|
-
|
|
42
|
+
rows[index] = '';
|
|
41
43
|
}
|
|
42
44
|
});
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
if (isUnidimensionalArray(rows)) {
|
|
48
|
+
rows = [rows];
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
return (
|
|
46
52
|
<table
|
|
47
53
|
class="el-table__footer"
|
|
@@ -57,24 +63,32 @@ export default {
|
|
|
57
63
|
}
|
|
58
64
|
</colgroup>
|
|
59
65
|
<tbody class={ [{ 'has-gutter': this.hasGutter }] }>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
{
|
|
67
|
+
rows.map((row, $index) => (
|
|
68
|
+
<tr>
|
|
69
|
+
{
|
|
70
|
+
this.columns.map((column, cellIndex) => {
|
|
71
|
+
const { rowspan, colspan } = this.getSpan(row, column, $index, cellIndex);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<td
|
|
75
|
+
key={ cellIndex }
|
|
76
|
+
rowspan={rowspan}
|
|
77
|
+
colspan={colspan}
|
|
78
|
+
class={ [...this.getRowClasses(column, cellIndex), 'el-table__cell'] }>
|
|
79
|
+
<div class={ ['cell', column.labelClassName] }>
|
|
80
|
+
{ row[cellIndex] }
|
|
81
|
+
</div>
|
|
82
|
+
</td>
|
|
83
|
+
);
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
{
|
|
87
|
+
this.hasGutter ? <th class="el-table__cell gutter"></th> : ''
|
|
88
|
+
}
|
|
89
|
+
</tr>
|
|
90
|
+
))
|
|
91
|
+
}
|
|
78
92
|
</tbody>
|
|
79
93
|
</table>
|
|
80
94
|
);
|
|
@@ -148,6 +162,23 @@ export default {
|
|
|
148
162
|
classes.push('is-leaf');
|
|
149
163
|
}
|
|
150
164
|
return classes;
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
getSpan(row, column, rowIndex, columnIndex) {
|
|
168
|
+
let rowspan = 1;
|
|
169
|
+
let colspan = 1;
|
|
170
|
+
const fn = this.table.spanMethod;
|
|
171
|
+
if (typeof fn === 'function') {
|
|
172
|
+
const result = fn({ row, column, rowIndex, columnIndex });
|
|
173
|
+
if (Array.isArray(result)) {
|
|
174
|
+
rowspan = result[0];
|
|
175
|
+
colspan = result[1];
|
|
176
|
+
} else if (typeof result === 'object') {
|
|
177
|
+
rowspan = result.rowspan;
|
|
178
|
+
colspan = result.colspan;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return { rowspan, colspan };
|
|
151
182
|
}
|
|
152
183
|
}
|
|
153
184
|
};
|
package/src/index.js
CHANGED
package/src/utils/util.js
CHANGED
|
@@ -259,3 +259,7 @@ export function getExternalScalingRatio(el) {
|
|
|
259
259
|
const scaleMatch = transform.match(/scale\(([^)]+)\)/);
|
|
260
260
|
return scaleMatch ? Number(scaleMatch[1]) : 1;
|
|
261
261
|
}
|
|
262
|
+
|
|
263
|
+
export function isUnidimensionalArray(arr) {
|
|
264
|
+
return Array.isArray(arr) && !arr.every(item => Array.isArray(item));
|
|
265
|
+
}
|