1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
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
99
100
101
102
103
104
105
import _extends from 'babel-runtime/helpers/extends';
import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray';
import _mergeJSXProps from 'babel-helper-vue-jsx-merge-props';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
/* eslint-disable no-console,func-names,react/no-multi-comp */
import Table from '../index';
import '../assets/index.less';
import BaseMixin from '../../_util/BaseMixin';
var ResizeableTitle = function ResizeableTitle(h, props, children) {
console.log(props);
var width = props.width,
restProps = _objectWithoutProperties(props, ['width']);
if (!width) {
return h(
'th',
restProps,
[children]
);
}
return h(
'th',
_mergeJSXProps([restProps, {
attrs: { width: width }
}]),
[children]
);
};
export default {
mixins: [BaseMixin],
data: function data() {
var h = this.$createElement;
return {
columns: [{ title: 'title1', dataIndex: 'a', key: 'a', width: 100 }, { id: '123', title: 'title2', dataIndex: 'b', key: 'b', width: 100 }, { title: 'title3', dataIndex: 'c', key: 'c', width: 200 }, {
title: 'Operations',
dataIndex: '',
key: 'd',
customRender: function customRender() {
return h(
'a',
{
attrs: { href: '#' }
},
['Operations']
);
}
}],
data: [{ a: '123', key: '1' }, { a: 'cdd', b: 'edd', key: '2' }, { a: '1333', c: 'eee', d: 2, key: '3' }],
components: {
header: {
cell: ResizeableTitle
}
}
};
},
methods: {
handleResize: function handleResize(index) {
var _this = this;
return function (e, _ref) {
var size = _ref.size;
_this.setState(function (_ref2) {
var columns = _ref2.columns;
var nextColumns = [].concat(_toConsumableArray(columns));
nextColumns[index] = _extends({}, nextColumns[index], {
width: size.width
});
return { columns: nextColumns };
});
};
}
},
render: function render() {
var _this2 = this;
var h = arguments[0];
var columns = this.columns.map(function (col, index) {
return _extends({}, col, {
customHeaderCell: function customHeaderCell(column) {
return {
props: {
width: column.width
},
on: {
resize: _this2.handleResize(index)
}
};
}
});
});
return h('div', [h('h2', ['Integrate with react-resizable']), h(Table, {
attrs: { components: this.components, columns: columns, data: this.data }
})]);
}
};