Skip to content

Commit a769ef4

Browse files
committed
update
1 parent b3f9eaf commit a769ef4

7 files changed

Lines changed: 103 additions & 71 deletions

File tree

.eslintrc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// https://eslint.org/docs/user-guide/configuring
22

33
module.exports = {
4+
root: true,
5+
parser: '@typescript-eslint/parser',
46
parserOptions: {
57
ecmaVersion: 6,
68
sourceType: 'module',
@@ -15,10 +17,10 @@ module.exports = {
1517
node: true
1618
},
1719
plugins: [
18-
'import'
20+
'@typescript-eslint'
1921
],
2022
extends: [
21-
'plugin:import/errors',
23+
'prettier/@typescript-eslint',
2224
'standard'
2325
],
2426
rules: {

dist/index.common.js

Lines changed: 37 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
(function (global, factory) {
22
if (typeof define === "function" && define.amd) {
3-
define("vxe-table-plugin-renderer", [], factory);
3+
define("vxe-table-plugin-renderer", ["exports", "xe-utils"], factory);
44
} else if (typeof exports !== "undefined") {
5-
factory();
5+
factory(exports, require("xe-utils"));
66
} else {
77
var mod = {
88
exports: {}
99
};
10-
factory();
10+
factory(mod.exports, global.XEUtils);
1111
global.VXETablePluginRenderer = mod.exports.default;
1212
}
13-
})(this, function () {
13+
})(this, function (_exports, _xeUtils) {
1414
"use strict";
1515

16-
exports.__esModule = true;
16+
Object.defineProperty(_exports, "__esModule", {
17+
value: true
18+
});
19+
_exports["default"] = _exports.VXETablePluginRenderer = void 0;
20+
_xeUtils = _interopRequireDefault(_xeUtils);
1721

18-
var xe_utils_1 = require("xe-utils");
22+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1923

24+
// import { VXETable } from 'vxe-table'
2025
function getCursorPosition(textarea) {
2126
var rangeData = {
2227
text: '',
@@ -50,8 +55,8 @@
5055
}
5156

5257
function autoResizeTextarea(evnt, renderOpts, params) {
53-
var _a = renderOpts.props,
54-
props = _a === void 0 ? {} : _a;
58+
var _renderOpts$props = renderOpts.props,
59+
props = _renderOpts$props === void 0 ? {} : _renderOpts$props;
5560
var $table = params.$table,
5661
column = params.column;
5762
var minWidth = column.renderWidth,
@@ -60,16 +65,16 @@
6065

6166
var maxWidth = props.maxWidth || 600;
6267
var maxHeight = props.maxHeight || 400;
63-
$text.textContent = inpElem.value + "\n";
64-
$text.style.maxWidth = maxWidth + "px";
68+
$text.textContent = "".concat(inpElem.value, "\n");
69+
$text.style.maxWidth = "".concat(maxWidth, "px");
6570

6671
if (!$text.parentNode) {
6772
$table.$el.appendChild($text);
6873
}
6974

7075
var height = Math.min(maxHeight, $text.offsetHeight + 4);
71-
inpElem.style.width = Math.min(maxWidth, Math.max(minWidth, $text.offsetWidth + 20)) + "px";
72-
inpElem.style.height = (height < minHeight ? minHeight : height) + "px";
76+
inpElem.style.width = "".concat(Math.min(maxWidth, Math.max(minWidth, $text.offsetWidth + 20)), "px");
77+
inpElem.style.height = "".concat(height < minHeight ? minHeight : height, "px");
7378
inpElem.style.overflowY = height > maxWidth ? 'auto' : '';
7479
}
7580

@@ -88,7 +93,7 @@
8893
};
8994

9095
if (events) {
91-
xe_utils_1["default"].assign(on, xe_utils_1["default"].objectMap(events, function (cb) {
96+
_xeUtils["default"].assign(on, _xeUtils["default"].objectMap(events, function (cb) {
9297
return function () {
9398
cb.apply(null, [params].concat.apply(params, arguments));
9499
};
@@ -106,11 +111,11 @@
106111
XInput: {
107112
autofocus: '.x-input',
108113
renderEdit: function renderEdit(h, renderOpts, params) {
109-
var _a = renderOpts.props,
110-
props = _a === void 0 ? {} : _a,
114+
var _renderOpts$props2 = renderOpts.props,
115+
props = _renderOpts$props2 === void 0 ? {} : _renderOpts$props2,
111116
attrs = renderOpts.attrs,
112-
_b = renderOpts.events,
113-
events = _b === void 0 ? {} : _b;
117+
_renderOpts$events = renderOpts.events,
118+
events = _renderOpts$events === void 0 ? {} : _renderOpts$events;
114119
var column = params.column;
115120
var model = column.model;
116121
var prefixIcon = props.prefixIcon,
@@ -123,7 +128,7 @@
123128
'is--suffix': props.suffixIcon
124129
}],
125130
style: {
126-
height: column.renderHeight - 1 + "px"
131+
height: "".concat(column.renderHeight - 1, "px")
127132
}
128133
}, [prefixIcon ? h('i', {
129134
"class": ['x-input--prefix', prefixIcon, {
@@ -175,15 +180,15 @@
175180
return [h('div', {
176181
"class": 'x-textarea--wrapper',
177182
style: {
178-
height: column.renderHeight - 1 + "px"
183+
height: "".concat(column.renderHeight - 1, "px")
179184
}
180185
}, [h('textarea', {
181186
"class": 'x-textarea',
182187
attrs: attrs,
183188
domProps: {
184189
value: model.value
185190
},
186-
on: xe_utils_1["default"].assign(getEvents(renderOpts, params), {
191+
on: _xeUtils["default"].assign(getEvents(renderOpts, params), {
187192
cut: autoResizeEvent,
188193
paste: autoResizeEvent,
189194
drop: autoResizeEvent,
@@ -192,17 +197,17 @@
192197
if (evnt.keyCode === 13 && (!$table.keyboardConfig || evnt.altKey)) {
193198
evnt.preventDefault();
194199
evnt.stopPropagation();
195-
var inpElem_1 = evnt.target;
196-
var rangeData_1 = getCursorPosition(inpElem_1);
197-
var pos_1 = rangeData_1.end;
198-
var cellValue = inpElem_1.value;
199-
cellValue = cellValue.slice(0, pos_1) + "\n" + cellValue.slice(pos_1, cellValue.length);
200-
inpElem_1.value = cellValue;
200+
var inpElem = evnt.target;
201+
var rangeData = getCursorPosition(inpElem);
202+
var pos = rangeData.end;
203+
var cellValue = inpElem.value;
204+
cellValue = "".concat(cellValue.slice(0, pos), "\n").concat(cellValue.slice(pos, cellValue.length));
205+
inpElem.value = cellValue;
201206
model.update = true;
202207
model.value = cellValue;
203208
setTimeout(function () {
204-
rangeData_1.start = rangeData_1.end = ++pos_1;
205-
setCursorPosition(inpElem_1, rangeData_1);
209+
rangeData.start = rangeData.end = ++pos;
210+
setCursorPosition(inpElem, rangeData);
206211
autoResizeEvent(evnt);
207212
});
208213
} else {
@@ -220,23 +225,25 @@
220225
column = params.column;
221226
return [h('span', {
222227
"class": 'x-textarea--content'
223-
}, xe_utils_1["default"].get(row, column.property))];
228+
}, _xeUtils["default"].get(row, column.property))];
224229
}
225230
}
226231
};
227232
/**
228233
* 基于 vxe-table 表格的增强插件,提供一些常用的渲染器
229234
*/
230235

231-
exports.VXETablePluginRenderer = {
236+
var VXETablePluginRenderer = {
232237
install: function install(xtable) {
233238
xtable.renderer.mixin(renderMap);
234239
}
235240
};
241+
_exports.VXETablePluginRenderer = VXETablePluginRenderer;
236242

237243
if (typeof window !== 'undefined' && window.VXETable) {
238-
window.VXETable.use(exports.VXETablePluginRenderer);
244+
window.VXETable.use(VXETablePluginRenderer);
239245
}
240246

241-
exports["default"] = exports.VXETablePluginRenderer;
247+
var _default = VXETablePluginRenderer;
248+
_exports["default"] = _default;
242249
});

dist/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ gulp.task('build_commonjs', function () {
3333
return gulp.src(['depend.ts', 'index.ts'])
3434
.pipe(sourcemaps.init())
3535
.pipe(ts({
36-
noImplicitAny: true
36+
noImplicitAny: true,
37+
target: 'es6'
3738
}))
3839
.pipe(babel({
3940
presets: ['@babel/env']
@@ -49,9 +50,10 @@ gulp.task('build_commonjs', function () {
4950
gulp.task('build_umd', function () {
5051
return gulp.src(['depend.ts', 'index.ts'])
5152
.pipe(ts({
52-
noImplicitAny: true
53+
noImplicitAny: true,
54+
target: 'es6'
5355
}))
54-
.pipe(replace(`require("xe-utils/methods/xe-utils")`, `require("xe-utils")`))
56+
.pipe(replace(`import XEUtils from 'xe-utils/methods/xe-utils';`, `import XEUtils from 'xe-utils';`))
5557
.pipe(babel({
5658
moduleId: pack.name,
5759
presets: ['@babel/env'],

index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import XEUtils from 'xe-utils/methods/xe-utils'
2-
import { VXETable } from 'vxe-table'
2+
// import { VXETable } from 'vxe-table'
33

44
function getCursorPosition (textarea: HTMLTextAreaElement) {
55
let rangeData = { text: '', start: 0, end: 0 }
@@ -189,11 +189,17 @@ const renderMap = {
189189
* 基于 vxe-table 表格的增强插件,提供一些常用的渲染器
190190
*/
191191
export const VXETablePluginRenderer = {
192-
install (xtable: typeof VXETable) {
192+
install (xtable: any) {
193193
xtable.renderer.mixin(renderMap)
194194
}
195195
}
196196

197+
declare global {
198+
interface Window {
199+
VXETable: any
200+
}
201+
}
202+
197203
if (typeof window !== 'undefined' && window.VXETable) {
198204
window.VXETable.use(VXETablePluginRenderer)
199205
}

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "vxe-table-plugin-renderer",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "基于 vxe-table 表格的增强插件,提供一些常用的渲染器",
55
"scripts": {
66
"lib": "gulp build"
77
},
88
"files": [
99
"dist",
1010
"index.ts",
11+
"index.d.ts",
1112
"style.scss"
1213
],
1314
"main": "dist/index.common.js",
@@ -20,14 +21,19 @@
2021
"@babel/plugin-transform-runtime": "^7.4.4",
2122
"@babel/preset-env": "^7.4.4",
2223
"@babel/runtime": "^7.4.4",
24+
"@typescript-eslint/eslint-plugin": "^2.3.1",
25+
"@typescript-eslint/parser": "^2.3.1",
2326
"del": "^5.1.0",
2427
"eslint": "^5.15.1",
28+
"eslint-config-prettier": "^6.3.0",
2529
"eslint-config-standard": "^12.0.0",
2630
"eslint-friendly-formatter": "^4.0.1",
2731
"eslint-plugin-import": "^2.16.0",
2832
"eslint-plugin-node": "^8.0.1",
33+
"eslint-plugin-prettier": "^3.1.1",
2934
"eslint-plugin-promise": "^4.0.1",
3035
"eslint-plugin-standard": "^4.0.0",
36+
"eslint-plugin-typescript": "^0.14.0",
3137
"gulp": "^4.0.2",
3238
"gulp-autoprefixer": "^6.1.0",
3339
"gulp-babel": "^8.0.0",
@@ -40,9 +46,10 @@
4046
"gulp-typescript": "^5.0.1",
4147
"gulp-uglify": "^3.0.2",
4248
"markdown-doctest": "^0.9.1",
49+
"prettier": "^1.18.2",
4350
"typescript": "^3.6.3",
4451
"vue": "^2.6.10",
45-
"vxe-table": "^2.5.22",
52+
"vxe-table": "^2.6.0-beta.6",
4653
"xe-utils": "^2.2.6"
4754
},
4855
"peerDependencies": {

0 commit comments

Comments
 (0)