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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _babelHelperVueJsxMergeProps = require('babel-helper-vue-jsx-merge-props');
var _babelHelperVueJsxMergeProps2 = _interopRequireDefault(_babelHelperVueJsxMergeProps);
var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
var _index = require('../index');
var _index2 = _interopRequireDefault(_index);
require('../assets/index.less');
var _BaseMixin = require('../../_util/BaseMixin');
var _BaseMixin2 = _interopRequireDefault(_BaseMixin);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var ResizeableTitle = function ResizeableTitle(h, props, children) {
console.log(props);
var width = props.width,
restProps = (0, _objectWithoutProperties3['default'])(props, ['width']);
if (!width) {
return h(
'th',
restProps,
[children]
);
}
return h(
'th',
(0, _babelHelperVueJsxMergeProps2['default'])([restProps, {
attrs: { width: width }
}]),
[children]
);
}; /* eslint-disable no-console,func-names,react/no-multi-comp */
exports['default'] = {
mixins: [_BaseMixin2['default']],
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((0, _toConsumableArray3['default'])(columns));
nextColumns[index] = (0, _extends3['default'])({}, 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 (0, _extends3['default'])({}, 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(_index2['default'], {
attrs: { components: this.components, columns: columns, data: this.data }
})]);
}
};