linkmore-design 1.0.76 → 1.0.77
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/dist/LmFilter/LmFilter.d.ts +1 -0
- package/dist/LmFilter/filterFns/index.d.ts +10 -1
- package/dist/LmTable/components/inputDataEdit.d.ts +8 -0
- package/dist/LmTable/components/sheelTableCell.d.ts +11 -0
- package/dist/LmTable/components/tableChartsModal.d.ts +22 -0
- package/dist/LmTable/demos/excel.d.ts +2 -0
- package/dist/index.umd.js +75075 -3350
- package/dist/index.umd.min.js +6 -6
- package/es/LmFilter/LmFilter.js +11 -3
- package/es/LmFilter/baseFilter/fuzzySearch.js +23 -13
- package/es/LmFilter/clearFilter/index.js +1 -3
- package/es/LmFilter/complexFilter/valueDrawer.js +1 -1
- package/es/LmFilter/filterFns/index.js +266 -92
- package/es/LmFilter/wrapper/FilterRoot.js +24 -2
- package/es/LmTable/Table.js +487 -43
- package/es/LmTable/components/inputDataEdit.d.ts +8 -0
- package/es/LmTable/components/inputDataEdit.js +35 -0
- package/es/LmTable/components/sheelTableCell.d.ts +11 -0
- package/es/LmTable/components/sheelTableCell.js +140 -0
- package/es/LmTable/components/tableChartsModal.d.ts +22 -0
- package/es/LmTable/components/tableChartsModal.js +114 -0
- package/es/LmTable/style/index.css +53 -0
- package/lib/LmFilter/LmFilter.js +11 -3
- package/lib/LmFilter/baseFilter/fuzzySearch.js +23 -13
- package/lib/LmFilter/clearFilter/index.js +1 -3
- package/lib/LmFilter/complexFilter/valueDrawer.js +1 -1
- package/lib/LmFilter/filterFns/index.js +266 -92
- package/lib/LmFilter/wrapper/FilterRoot.js +24 -2
- package/lib/LmTable/Table.js +487 -43
- package/lib/LmTable/components/inputDataEdit.d.ts +8 -0
- package/lib/LmTable/components/inputDataEdit.js +46 -0
- package/lib/LmTable/components/sheelTableCell.d.ts +11 -0
- package/lib/LmTable/components/sheelTableCell.js +155 -0
- package/lib/LmTable/components/tableChartsModal.d.ts +22 -0
- package/lib/LmTable/components/tableChartsModal.js +127 -0
- package/lib/LmTable/style/index.css +53 -0
- package/package.json +5 -4
- package/typings/index.d.ts +0 -19
package/es/LmTable/Table.js
CHANGED
|
@@ -39,20 +39,48 @@ var _reactResizable = require("react-resizable");
|
|
|
39
39
|
|
|
40
40
|
var _reactSortableHoc = require("react-sortable-hoc");
|
|
41
41
|
|
|
42
|
+
var _hooks = require("../hooks");
|
|
43
|
+
|
|
42
44
|
var _DndContainer = _interopRequireDefault(require("./components/DndContainer"));
|
|
43
45
|
|
|
44
46
|
var _sortableBoxCol = _interopRequireDefault(require("./components/sortableBoxCol"));
|
|
45
47
|
|
|
46
48
|
var _sortableItemCol = _interopRequireDefault(require("./components/sortableItemCol"));
|
|
47
49
|
|
|
50
|
+
var _sheelTableCell = _interopRequireDefault(require("./components/sheelTableCell"));
|
|
51
|
+
|
|
52
|
+
var _tableChartsModal = _interopRequireDefault(require("./components/tableChartsModal"));
|
|
53
|
+
|
|
48
54
|
var _resetConfig = _interopRequireDefault(require("./resetConfig"));
|
|
49
55
|
|
|
50
|
-
var _excluded = ["dataSource", "autoSize", "columns", "rowClick", "onDoubleClick", "checkConfig", "summary", "pagination", "hiddenPage", "loading", "virtual", "sortOpen", "colSortOpen", "resizeable", "customCheck", "components", "rowSelection", "columnsState", "onChange", "filterChange", "tableRowType", "size", "emptyProps"],
|
|
56
|
+
var _excluded = ["dataSource", "autoSize", "columns", "rowClick", "onDoubleClick", "checkConfig", "summary", "pagination", "hiddenPage", "loading", "virtual", "sortOpen", "colSortOpen", "resizeable", "customCheck", "components", "rowSelection", "columnsState", "onChange", "filterChange", "tableRowType", "size", "openSheet", "editSheet", "emptyProps"],
|
|
51
57
|
_excluded2 = ["className", "style"],
|
|
52
58
|
_excluded3 = ["onResize", "width", "onResizeStop"];
|
|
53
|
-
var Summary = _proTable.default.Summary;
|
|
54
|
-
|
|
59
|
+
var Summary = _proTable.default.Summary;
|
|
55
60
|
exports.Summary = Summary;
|
|
61
|
+
|
|
62
|
+
var isEmpty = function isEmpty(obj) {
|
|
63
|
+
return Object.keys(obj).length === 0;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
var defaultParsePaste = function defaultParsePaste(str) {
|
|
67
|
+
return str.split(/\r\n|\n|\r/).map(function (row) {
|
|
68
|
+
return row.split('\t');
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
var range = function range(start, end) {
|
|
73
|
+
var array = [];
|
|
74
|
+
var inc = end - start > 0;
|
|
75
|
+
|
|
76
|
+
for (var i = start; inc ? i <= end : i >= end; inc ? i++ : i--) {
|
|
77
|
+
inc ? array.push(i) : array.unshift(i);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return array;
|
|
81
|
+
}; // const DragHandle = SortableHandle(() => <MenuOutlined style={{ cursor: 'grab', color: '#999' }} />);
|
|
82
|
+
|
|
83
|
+
|
|
56
84
|
var DragHandle = (0, _reactSortableHoc.SortableHandle)(function () {
|
|
57
85
|
return /*#__PURE__*/_react.default.createElement(_linkmoreDesign.IconFont, {
|
|
58
86
|
type: "lmweb-icon-m-receipt1",
|
|
@@ -101,6 +129,10 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
101
129
|
tableRowType = _props$tableRowType === void 0 ? 'default' : _props$tableRowType,
|
|
102
130
|
_props$size = props.size,
|
|
103
131
|
size = _props$size === void 0 ? 'default' : _props$size,
|
|
132
|
+
_props$openSheet = props.openSheet,
|
|
133
|
+
openSheet = _props$openSheet === void 0 ? false : _props$openSheet,
|
|
134
|
+
_props$editSheet = props.editSheet,
|
|
135
|
+
editSheet = _props$editSheet === void 0 ? false : _props$editSheet,
|
|
104
136
|
emptyProps = props.emptyProps,
|
|
105
137
|
resetProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
106
138
|
var _resetProps$rowKey = resetProps.rowKey,
|
|
@@ -123,13 +155,73 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
123
155
|
var _useState5 = (0, _react.useState)([]),
|
|
124
156
|
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
125
157
|
useColumns = _useState6[0],
|
|
126
|
-
setColumns = _useState6[1];
|
|
127
|
-
|
|
158
|
+
setColumns = _useState6[1];
|
|
128
159
|
|
|
129
|
-
var
|
|
160
|
+
var tableWarpRef = (0, _react.useRef)(null);
|
|
161
|
+
/** 右键的ref */
|
|
162
|
+
|
|
163
|
+
var contentMenuRef = (0, _react.useRef)(null);
|
|
164
|
+
/** sheel数据的表格 */
|
|
165
|
+
|
|
166
|
+
var _useState7 = (0, _react.useState)({
|
|
167
|
+
start: {},
|
|
168
|
+
end: {},
|
|
169
|
+
selecting: false,
|
|
170
|
+
forceEdit: false,
|
|
171
|
+
editing: {},
|
|
172
|
+
clear: {}
|
|
173
|
+
}),
|
|
130
174
|
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
131
|
-
|
|
132
|
-
|
|
175
|
+
sheelStataus = _useState8[0],
|
|
176
|
+
setSheelStatus = _useState8[1];
|
|
177
|
+
|
|
178
|
+
var shellStatusRef = (0, _react.useRef)({
|
|
179
|
+
start: {},
|
|
180
|
+
end: {},
|
|
181
|
+
selecting: false,
|
|
182
|
+
forceEdit: false,
|
|
183
|
+
editing: {},
|
|
184
|
+
clear: {}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
var _useState9 = (0, _react.useState)(false),
|
|
188
|
+
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
189
|
+
selectIng = _useState10[0],
|
|
190
|
+
SetSelectIng = _useState10[1];
|
|
191
|
+
|
|
192
|
+
var _useState11 = (0, _react.useState)(false),
|
|
193
|
+
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
194
|
+
editIng = _useState12[0],
|
|
195
|
+
setEditIng = _useState12[1];
|
|
196
|
+
/** 右键菜单是否显示 */
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
var _useState13 = (0, _react.useState)(false),
|
|
200
|
+
_useState14 = (0, _slicedToArray2.default)(_useState13, 2),
|
|
201
|
+
contextMenuStatus = _useState14[0],
|
|
202
|
+
setContextMenuStatus = _useState14[1];
|
|
203
|
+
/** 右键按钮的位置 */
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
var _useState15 = (0, _react.useState)({
|
|
207
|
+
position: 'fixed',
|
|
208
|
+
left: 300,
|
|
209
|
+
top: 200
|
|
210
|
+
}),
|
|
211
|
+
_useState16 = (0, _slicedToArray2.default)(_useState15, 2),
|
|
212
|
+
style = _useState16[0],
|
|
213
|
+
setStyle = _useState16[1];
|
|
214
|
+
|
|
215
|
+
var _useState17 = (0, _react.useState)(null),
|
|
216
|
+
_useState18 = (0, _slicedToArray2.default)(_useState17, 2),
|
|
217
|
+
chartsModalStatus = _useState18[0],
|
|
218
|
+
setChartsModalStatus = _useState18[1]; // 列设置
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
var _useState19 = (0, _react.useState)(false),
|
|
222
|
+
_useState20 = (0, _slicedToArray2.default)(_useState19, 2),
|
|
223
|
+
columnsStateMap = _useState20[0],
|
|
224
|
+
setColumnsStateMap = _useState20[1];
|
|
133
225
|
|
|
134
226
|
var SortableItem = (0, _reactSortableHoc.SortableElement)(function (props) {
|
|
135
227
|
return /*#__PURE__*/_react.default.createElement("tr", props);
|
|
@@ -202,12 +294,318 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
202
294
|
filterChange === null || filterChange === void 0 ? void 0 : filterChange(useColumns);
|
|
203
295
|
});
|
|
204
296
|
};
|
|
297
|
+
/** 复制功能 */
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
var handleCopy = function handleCopy(e) {
|
|
301
|
+
var _shellStatusRef$curre;
|
|
302
|
+
|
|
303
|
+
if (isEmpty((_shellStatusRef$curre = shellStatusRef.current) === null || _shellStatusRef$curre === void 0 ? void 0 : _shellStatusRef$curre.editing)) {
|
|
304
|
+
var _e$clipboardData;
|
|
305
|
+
|
|
306
|
+
e.preventDefault();
|
|
307
|
+
var _shellStatusRef$curre2 = shellStatusRef.current,
|
|
308
|
+
start = _shellStatusRef$curre2.start,
|
|
309
|
+
end = _shellStatusRef$curre2.end;
|
|
310
|
+
var text = range(start.i, end.i).map(function (i) {
|
|
311
|
+
return range(start.j, end.j).map(function (j) {
|
|
312
|
+
var _columns$j, _columns$j2;
|
|
313
|
+
|
|
314
|
+
var columnKey = (_columns$j = columns[j]) === null || _columns$j === void 0 ? void 0 : _columns$j.dataIndex;
|
|
315
|
+
var dataItem = dataSource[i];
|
|
316
|
+
var cell = dataItem[columnKey];
|
|
317
|
+
|
|
318
|
+
if ((_columns$j2 = columns[j]) === null || _columns$j2 === void 0 ? void 0 : _columns$j2.render) {
|
|
319
|
+
var _columns$j3, _columns$j3$render;
|
|
320
|
+
|
|
321
|
+
return (_columns$j3 = columns[j]) === null || _columns$j3 === void 0 ? void 0 : (_columns$j3$render = _columns$j3.render) === null || _columns$j3$render === void 0 ? void 0 : _columns$j3$render.call(_columns$j3, cell, dataItem, i);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return cell;
|
|
325
|
+
}).join('\t');
|
|
326
|
+
}).join('\n');
|
|
327
|
+
|
|
328
|
+
if (window.clipboardData && window.clipboardData.setData) {
|
|
329
|
+
window.clipboardData.setData('Text', text);
|
|
330
|
+
} else if ((_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.setData) {
|
|
331
|
+
e.clipboardData.setData('text/plain', text);
|
|
332
|
+
} else {
|
|
333
|
+
var _document;
|
|
334
|
+
|
|
335
|
+
(_document = document) === null || _document === void 0 ? void 0 : _document.execCommand('copy');
|
|
336
|
+
|
|
337
|
+
if (contextMenuStatus) {
|
|
338
|
+
setContextMenuStatus(false);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
var onMouseOver = function onMouseOver(i, j) {
|
|
345
|
+
var _shellStatusRef$curre3, _shellStatusRef$curre4;
|
|
346
|
+
|
|
347
|
+
if (((_shellStatusRef$curre3 = shellStatusRef.current) === null || _shellStatusRef$curre3 === void 0 ? void 0 : _shellStatusRef$curre3.selecting) && isEmpty((_shellStatusRef$curre4 = shellStatusRef.current) === null || _shellStatusRef$curre4 === void 0 ? void 0 : _shellStatusRef$curre4.editing)) {
|
|
348
|
+
shellStatusRef.current = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, shellStatusRef.current), {}, {
|
|
349
|
+
end: {
|
|
350
|
+
i: i,
|
|
351
|
+
j: j
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
setSheelStatus((0, _objectSpread2.default)((0, _objectSpread2.default)({}, sheelStataus), {}, {
|
|
355
|
+
end: {
|
|
356
|
+
i: i,
|
|
357
|
+
j: j
|
|
358
|
+
}
|
|
359
|
+
}));
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
/** sheel 表格 鼠标松开 */
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
var sheelOnMouseUp = function sheelOnMouseUp() {
|
|
366
|
+
setSheelStatus((0, _objectSpread2.default)((0, _objectSpread2.default)({}, sheelStataus), {}, {
|
|
367
|
+
selecting: false
|
|
368
|
+
}));
|
|
369
|
+
shellStatusRef.current = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, shellStatusRef.current), {}, {
|
|
370
|
+
selecting: false
|
|
371
|
+
});
|
|
372
|
+
document.removeEventListener('mouseup', sheelOnMouseUp);
|
|
373
|
+
};
|
|
374
|
+
/** 剪切内容 */
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
var handleCut = function handleCut(e) {
|
|
378
|
+
var _shellStatusRef$curre5;
|
|
379
|
+
|
|
380
|
+
if (isEmpty((_shellStatusRef$curre5 = shellStatusRef.current) === null || _shellStatusRef$curre5 === void 0 ? void 0 : _shellStatusRef$curre5.editing)) {
|
|
381
|
+
e.preventDefault();
|
|
382
|
+
handleCopy(e);
|
|
383
|
+
var _shellStatusRef$curre6 = shellStatusRef.current,
|
|
384
|
+
start = _shellStatusRef$curre6.start,
|
|
385
|
+
end = _shellStatusRef$curre6.end;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
/** 内容粘贴 */
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
var handlePaste = function handlePaste(e) {
|
|
392
|
+
if (isEmpty(sheelStataus.editing)) {
|
|
393
|
+
var start = sheelStataus.start,
|
|
394
|
+
end = sheelStataus.end;
|
|
395
|
+
start = {
|
|
396
|
+
i: Math.min(start.i, end.i),
|
|
397
|
+
j: Math.min(start.j, end.j)
|
|
398
|
+
};
|
|
399
|
+
end = {
|
|
400
|
+
i: Math.max(start.i, end.i),
|
|
401
|
+
j: Math.max(start.j, end.j)
|
|
402
|
+
};
|
|
403
|
+
var parse = props.parsePaste || defaultParsePaste;
|
|
404
|
+
var changes = [];
|
|
405
|
+
var pasteData = [];
|
|
406
|
+
|
|
407
|
+
if (window.clipboardData && window.clipboardData.getData) {
|
|
408
|
+
// IE
|
|
409
|
+
pasteData = parse(window.clipboardData.getData('Text'));
|
|
410
|
+
} else if (e.clipboardData && e.clipboardData.getData) {
|
|
411
|
+
pasteData = parse(e.clipboardData.getData('text/plain'));
|
|
412
|
+
} // in order of preference
|
|
413
|
+
// const { data, onCellsChanged, onPaste, onChange } = this.props
|
|
414
|
+
// if (onCellsChanged) {
|
|
415
|
+
// const additions = []
|
|
416
|
+
// pasteData.forEach((row, i) => {
|
|
417
|
+
// row.forEach((value, j) => {
|
|
418
|
+
// end = { i: start.i + i, j: start.j + j }
|
|
419
|
+
// const cell = data[end.i] && data[end.i][end.j]
|
|
420
|
+
// if (!cell) {
|
|
421
|
+
// additions.push({ row: end.i, col: end.j, value })
|
|
422
|
+
// } else if (!cell.readOnly) {
|
|
423
|
+
// changes.push({ cell, row: end.i, col: end.j, value })
|
|
424
|
+
// }
|
|
425
|
+
// })
|
|
426
|
+
// })
|
|
427
|
+
// if (additions.length) {
|
|
428
|
+
// onCellsChanged(changes, additions)
|
|
429
|
+
// } else {
|
|
430
|
+
// onCellsChanged(changes)
|
|
431
|
+
// }
|
|
432
|
+
// } else if (onPaste) {
|
|
433
|
+
// pasteData.forEach((row, i) => {
|
|
434
|
+
// const rowData = []
|
|
435
|
+
// row.forEach((pastedData, j) => {
|
|
436
|
+
// end = { i: start.i + i, j: start.j + j }
|
|
437
|
+
// const cell = data[end.i] && data[end.i][end.j]
|
|
438
|
+
// rowData.push({ cell: cell, data: pastedData })
|
|
439
|
+
// })
|
|
440
|
+
// changes.push(rowData)
|
|
441
|
+
// })
|
|
442
|
+
// onPaste(changes)
|
|
443
|
+
// } else if (onChange) {
|
|
444
|
+
// pasteData.forEach((row, i) => {
|
|
445
|
+
// row.forEach((value, j) => {
|
|
446
|
+
// end = { i: start.i + i, j: start.j + j }
|
|
447
|
+
// const cell = data[end.i] && data[end.i][end.j]
|
|
448
|
+
// if (cell && !cell.readOnly) {
|
|
449
|
+
// onChange(cell, end.i, end.j, value)
|
|
450
|
+
// }
|
|
451
|
+
// })
|
|
452
|
+
// })
|
|
453
|
+
// }
|
|
454
|
+
// this._setState({ end })
|
|
455
|
+
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
var pageClick = function pageClick(e) {
|
|
460
|
+
// if (this.props.disablePageClick) return;
|
|
461
|
+
var element = tableWarpRef.current;
|
|
462
|
+
|
|
463
|
+
if (!(element === null || element === void 0 ? void 0 : element.contains(e.target))) {
|
|
464
|
+
shellStatusRef.current = {
|
|
465
|
+
start: {},
|
|
466
|
+
end: {},
|
|
467
|
+
selecting: false,
|
|
468
|
+
forceEdit: false,
|
|
469
|
+
editing: {},
|
|
470
|
+
clear: {}
|
|
471
|
+
};
|
|
472
|
+
SetSelectIng(false);
|
|
473
|
+
document.removeEventListener('mousedown', pageClick);
|
|
474
|
+
document.removeEventListener('mouseup', sheelOnMouseUp);
|
|
475
|
+
document.removeEventListener('cut', handleCut);
|
|
476
|
+
document.removeEventListener('copy', handleCopy);
|
|
477
|
+
document.removeEventListener('paste', handlePaste);
|
|
478
|
+
}
|
|
479
|
+
/** 关闭右键 */
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
var contentElement = contentMenuRef.current;
|
|
483
|
+
|
|
484
|
+
if (!(contentElement === null || contentElement === void 0 ? void 0 : contentElement.contains(e.target))) {
|
|
485
|
+
setContextMenuStatus(false);
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
/** sheel 表格 鼠标点击 */
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
var sheelMouseDown = function sheelMouseDown(i, j, e) {
|
|
492
|
+
var _shellStatusRef$curre7, _shellStatusRef$curre8, _shellStatusRef$curre9, _shellStatusRef$curre10, _shellStatusRef$curre11, _shellStatusRef$curre12, _shellStatusRef$curre13, _shellStatusRef$curre14, _shellStatusRef$curre15;
|
|
493
|
+
|
|
494
|
+
var isNowEditingSameCell = !isEmpty((_shellStatusRef$curre7 = shellStatusRef.current) === null || _shellStatusRef$curre7 === void 0 ? void 0 : _shellStatusRef$curre7.editing) && ((_shellStatusRef$curre8 = shellStatusRef.current) === null || _shellStatusRef$curre8 === void 0 ? void 0 : _shellStatusRef$curre8.editing.i) === i && ((_shellStatusRef$curre9 = shellStatusRef.current) === null || _shellStatusRef$curre9 === void 0 ? void 0 : _shellStatusRef$curre9.editing.j) === j;
|
|
495
|
+
var editing = isEmpty((_shellStatusRef$curre10 = shellStatusRef.current) === null || _shellStatusRef$curre10 === void 0 ? void 0 : _shellStatusRef$curre10.editing) || ((_shellStatusRef$curre11 = shellStatusRef.current) === null || _shellStatusRef$curre11 === void 0 ? void 0 : _shellStatusRef$curre11.editing.i) !== i || ((_shellStatusRef$curre12 = shellStatusRef.current) === null || _shellStatusRef$curre12 === void 0 ? void 0 : _shellStatusRef$curre12.editing.j) !== j ? {} : (_shellStatusRef$curre13 = shellStatusRef.current) === null || _shellStatusRef$curre13 === void 0 ? void 0 : _shellStatusRef$curre13.editing;
|
|
496
|
+
shellStatusRef.current = {
|
|
497
|
+
selecting: !isNowEditingSameCell,
|
|
498
|
+
start: (e === null || e === void 0 ? void 0 : e.shiftKey) ? (_shellStatusRef$curre14 = shellStatusRef.current) === null || _shellStatusRef$curre14 === void 0 ? void 0 : _shellStatusRef$curre14.start : {
|
|
499
|
+
i: i,
|
|
500
|
+
j: j
|
|
501
|
+
},
|
|
502
|
+
end: {
|
|
503
|
+
i: i,
|
|
504
|
+
j: j
|
|
505
|
+
},
|
|
506
|
+
editing: editing,
|
|
507
|
+
forceEdit: !!isNowEditingSameCell
|
|
508
|
+
};
|
|
509
|
+
SetSelectIng(!isNowEditingSameCell);
|
|
510
|
+
|
|
511
|
+
if (isEmpty((_shellStatusRef$curre15 = shellStatusRef.current) === null || _shellStatusRef$curre15 === void 0 ? void 0 : _shellStatusRef$curre15.editing)) {
|
|
512
|
+
setEditIng(false);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
document.addEventListener('mouseup', sheelOnMouseUp);
|
|
516
|
+
document.addEventListener('mousedown', pageClick);
|
|
517
|
+
document.addEventListener('cut', handleCut);
|
|
518
|
+
document.addEventListener('copy', handleCopy);
|
|
519
|
+
document.addEventListener('paste', handlePaste);
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
var onContextMenu = function onContextMenu(evt, i, j) {
|
|
523
|
+
evt.preventDefault();
|
|
524
|
+
var _shellStatusRef$curre16 = shellStatusRef.current,
|
|
525
|
+
start = _shellStatusRef$curre16.start,
|
|
526
|
+
end = _shellStatusRef$curre16.end;
|
|
527
|
+
|
|
528
|
+
if (isEmpty(start) && isEmpty(end)) {
|
|
529
|
+
sheelMouseDown(i, j, evt);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
setContextMenuStatus(true); // 获得点击的位置
|
|
533
|
+
|
|
534
|
+
var clientX = evt.clientX,
|
|
535
|
+
clientY = evt.clientY; // 文档显示区的宽度
|
|
536
|
+
|
|
537
|
+
var screenW = window.innerWidth;
|
|
538
|
+
var screenH = window.innerHeight; // 右键菜单的宽度
|
|
539
|
+
// const rightClickRefW = rightClickRef.current.offsetWidth;
|
|
540
|
+
// const rightClickRefH = rightClickRef.current.offsetHeight;
|
|
541
|
+
|
|
542
|
+
var rightClickRefW = 200;
|
|
543
|
+
var rightClickRefH = 200; // right为true,说明鼠标点击的位置到浏览器的右边界的宽度可以放下contextmenu。
|
|
544
|
+
// 否则,菜单放到左边。
|
|
545
|
+
|
|
546
|
+
var right = screenW - clientX > rightClickRefW;
|
|
547
|
+
var top = screenH - clientY > rightClickRefH; // 赋值右键菜单离鼠标一些距离
|
|
548
|
+
|
|
549
|
+
clientX = right ? clientX + 6 : clientX - rightClickRefW - 6;
|
|
550
|
+
clientY = top ? clientY + 6 : clientY - rightClickRefH - 6;
|
|
551
|
+
setStyle((0, _objectSpread2.default)((0, _objectSpread2.default)({}, style), {}, {
|
|
552
|
+
left: clientX,
|
|
553
|
+
top: clientY
|
|
554
|
+
}));
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
var onSheelDoubleClick = function onSheelDoubleClick(i, j, col) {
|
|
558
|
+
if (!col.readOnly) {
|
|
559
|
+
shellStatusRef.current = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, shellStatusRef.current), {}, {
|
|
560
|
+
editing: {
|
|
561
|
+
i: i,
|
|
562
|
+
j: j
|
|
563
|
+
},
|
|
564
|
+
forceEdit: true,
|
|
565
|
+
clear: {}
|
|
566
|
+
});
|
|
567
|
+
setEditIng(true);
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
var dataSourceChange = function dataSourceChange(i, j, newRecord) {};
|
|
572
|
+
|
|
573
|
+
(0, _react.useEffect)(function () {
|
|
574
|
+
return function () {
|
|
575
|
+
document.removeEventListener('mousedown', pageClick);
|
|
576
|
+
document.removeEventListener('mouseup', sheelOnMouseUp);
|
|
577
|
+
document.removeEventListener('cut', handleCut);
|
|
578
|
+
document.removeEventListener('copy', handleCopy);
|
|
579
|
+
document.removeEventListener('paste', handlePaste);
|
|
580
|
+
};
|
|
581
|
+
}, []);
|
|
582
|
+
|
|
583
|
+
var isSelected = function isSelected(i, j) {
|
|
584
|
+
var _shellStatusRef$curre17 = shellStatusRef.current,
|
|
585
|
+
start = _shellStatusRef$curre17.start,
|
|
586
|
+
end = _shellStatusRef$curre17.end,
|
|
587
|
+
editing = _shellStatusRef$curre17.editing;
|
|
588
|
+
var maxi = Math.max(start === null || start === void 0 ? void 0 : start.i, end.i);
|
|
589
|
+
var mini = Math.min(start === null || start === void 0 ? void 0 : start.i, end.i);
|
|
590
|
+
var maxj = Math.max(start === null || start === void 0 ? void 0 : start.j, end.j);
|
|
591
|
+
var minj = Math.min(start === null || start === void 0 ? void 0 : start.j, end.j);
|
|
592
|
+
var posX = j >= start.j && j <= end.j;
|
|
593
|
+
var negX = j <= start.j && j >= end.j;
|
|
594
|
+
var posY = i >= start.i && i <= end.i;
|
|
595
|
+
var negY = i <= start.i && i >= end.i;
|
|
596
|
+
return {
|
|
597
|
+
isSelected: posX && posY || negX && posY || negX && negY || posX && negY,
|
|
598
|
+
isEnd: i === maxi && j >= minj && j <= maxj,
|
|
599
|
+
isRightEnd: j === maxj && i >= mini && i <= maxi,
|
|
600
|
+
isEditing: (editing === null || editing === void 0 ? void 0 : editing.i) === i && (editing === null || editing === void 0 ? void 0 : editing.j) === j
|
|
601
|
+
};
|
|
602
|
+
};
|
|
205
603
|
|
|
206
604
|
var resetColumns = (0, _react.useCallback)(function () {
|
|
207
605
|
var result = useColumns.filter(function (item) {
|
|
208
606
|
return item.show !== false;
|
|
209
607
|
}).map(function (col, index) {
|
|
210
|
-
|
|
608
|
+
var obj = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, col), {}, {
|
|
211
609
|
width: col.width,
|
|
212
610
|
onHeaderCell: function onHeaderCell(column) {
|
|
213
611
|
return {
|
|
@@ -218,9 +616,31 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
218
616
|
};
|
|
219
617
|
}
|
|
220
618
|
});
|
|
619
|
+
|
|
620
|
+
if (openSheet) {
|
|
621
|
+
obj.onCell = function (record, rowIndex) {
|
|
622
|
+
return {
|
|
623
|
+
record: record,
|
|
624
|
+
rowKey: rowKey,
|
|
625
|
+
col: col,
|
|
626
|
+
colIndex: index,
|
|
627
|
+
selectIng: selectIng,
|
|
628
|
+
editIng: editIng,
|
|
629
|
+
rowIndex: rowIndex,
|
|
630
|
+
onMouseDown: sheelMouseDown,
|
|
631
|
+
onMouseOver: onMouseOver,
|
|
632
|
+
onContextMenu: onContextMenu,
|
|
633
|
+
isSelected: isSelected,
|
|
634
|
+
onDoubleClick: onSheelDoubleClick,
|
|
635
|
+
dataSourceChange: dataSourceChange
|
|
636
|
+
};
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
return obj;
|
|
221
641
|
});
|
|
222
642
|
return sortOpen ? [sortDefaultColumnItem].concat((0, _toConsumableArray2.default)(result)) : result;
|
|
223
|
-
}, [useColumns, sortOpen]);
|
|
643
|
+
}, [useColumns, sortOpen, selectIng]);
|
|
224
644
|
(0, _react.useEffect)(function () {
|
|
225
645
|
setColumns(columns);
|
|
226
646
|
}, [columns]); // 行点击事件
|
|
@@ -350,18 +770,7 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
350
770
|
return (a.fixed === 'left' ? a.colSort : a.fixed === 'right' ? 500 + a.colSort : a.colSort + 50) - (b.fixed === 'left' ? b.colSort : b.fixed === 'right' ? 500 + b.colSort : b.colSort + 50);
|
|
351
771
|
});
|
|
352
772
|
return result;
|
|
353
|
-
}, [columnsStateMap, useColumns]);
|
|
354
|
-
// const countW = sumBy(columns, 'width') + 36
|
|
355
|
-
// const nValue = columns.map((col) => {
|
|
356
|
-
// const rw = countW < autoSize.width ? (autoSize.width / countW) * col.width : col.width
|
|
357
|
-
// return {
|
|
358
|
-
// ...col,
|
|
359
|
-
// width: round(rw),
|
|
360
|
-
// }
|
|
361
|
-
// })
|
|
362
|
-
// setColumns(nValue)
|
|
363
|
-
// }, [columns, autoSize.width])
|
|
364
|
-
|
|
773
|
+
}, [columnsStateMap, useColumns]);
|
|
365
774
|
(0, _react.useEffect)(function () {
|
|
366
775
|
var obj = (0, _objectSpread2.default)({}, columnsState);
|
|
367
776
|
columns === null || columns === void 0 ? void 0 : columns.forEach(function (item) {
|
|
@@ -375,19 +784,10 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
375
784
|
fixed: fixed || item.fixed,
|
|
376
785
|
show: show === false ? false : item.show || true,
|
|
377
786
|
order: order || item.order
|
|
378
|
-
};
|
|
379
|
-
// obj[item.dataIndex || item.key] = { ...(obj[item.dataIndex || item.key] || {}), fixed: item.fixed }
|
|
380
|
-
// }
|
|
787
|
+
};
|
|
381
788
|
});
|
|
382
789
|
setColumnsStateMap(obj);
|
|
383
|
-
}, [columnsState]); //
|
|
384
|
-
// console.log(props.columnsStateValue, 'v vv')
|
|
385
|
-
// setColumnsStateMap(props.columnsStateValue)
|
|
386
|
-
// }, [props.columnsStateValue])
|
|
387
|
-
// useEffect(() => {
|
|
388
|
-
// rowClick?.()
|
|
389
|
-
// }, [useSelectedRows])
|
|
390
|
-
// 将节点方法给外部使用
|
|
790
|
+
}, [columnsState]); // 将节点方法给外部使用
|
|
391
791
|
|
|
392
792
|
_react.default.useImperativeHandle(ref, function () {
|
|
393
793
|
return {
|
|
@@ -439,9 +839,7 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
439
839
|
var obj = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
|
|
440
840
|
sortOrder: false
|
|
441
841
|
});
|
|
442
|
-
obj.filteredValue = filters[obj.dataIndex] || [];
|
|
443
|
-
// obj['filteredValue'] = filters[obj.dataIndex]
|
|
444
|
-
// }
|
|
842
|
+
obj.filteredValue = filters[obj.dataIndex] || [];
|
|
445
843
|
|
|
446
844
|
if (Array.isArray(sorter)) {
|
|
447
845
|
var checkSort = sorter.find(function (s) {
|
|
@@ -506,7 +904,10 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
506
904
|
}));
|
|
507
905
|
}, [columns]);
|
|
508
906
|
var tableComponents = (0, _react.useMemo)(function () {
|
|
509
|
-
var obj = {
|
|
907
|
+
var obj = {// table: (record) => {
|
|
908
|
+
// return <div style={record.style}>{record.children}</div>
|
|
909
|
+
// }
|
|
910
|
+
};
|
|
510
911
|
|
|
511
912
|
if (sortOpen) {
|
|
512
913
|
obj.body = {
|
|
@@ -536,13 +937,23 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
536
937
|
obj.header = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, obj.header), header);
|
|
537
938
|
}
|
|
538
939
|
|
|
940
|
+
if (openSheet) {
|
|
941
|
+
if (obj.body) {
|
|
942
|
+
obj.body.cell = _sheelTableCell.default;
|
|
943
|
+
} else {
|
|
944
|
+
obj.body = {};
|
|
945
|
+
obj.body.cell = _sheelTableCell.default;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
539
949
|
return obj;
|
|
540
950
|
}, [sortOpen, resizeable, components, colSortOpen]);
|
|
541
951
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
542
952
|
style: {
|
|
543
953
|
height: '100%',
|
|
544
954
|
width: '100%'
|
|
545
|
-
}
|
|
955
|
+
},
|
|
956
|
+
ref: tableWarpRef
|
|
546
957
|
}, /*#__PURE__*/_react.default.createElement(_configProvider.default, {
|
|
547
958
|
renderEmpty: loading ? function () {
|
|
548
959
|
return null;
|
|
@@ -575,7 +986,40 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
575
986
|
}
|
|
576
987
|
}))), !!customCheck && /*#__PURE__*/_react.default.createElement("div", {
|
|
577
988
|
className: "lm_customCheck"
|
|
578
|
-
}, customCheck)
|
|
989
|
+
}, customCheck), contextMenuStatus && /*#__PURE__*/_react.default.createElement("div", {
|
|
990
|
+
ref: contentMenuRef,
|
|
991
|
+
className: "WeChatContactsAvatarTools",
|
|
992
|
+
style: style
|
|
993
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
994
|
+
className: "rightClickItems",
|
|
995
|
+
onClick: handleCopy
|
|
996
|
+
}, "\u590D\u5236"), /*#__PURE__*/_react.default.createElement("div", {
|
|
997
|
+
className: "rightClickItems",
|
|
998
|
+
onClick: function onClick() {
|
|
999
|
+
return setChartsModalStatus('column');
|
|
1000
|
+
}
|
|
1001
|
+
}, "\u751F\u6210\u67F1\u72B6\u56FE"), /*#__PURE__*/_react.default.createElement("div", {
|
|
1002
|
+
className: "rightClickItems",
|
|
1003
|
+
onClick: function onClick() {
|
|
1004
|
+
return setChartsModalStatus('pie');
|
|
1005
|
+
}
|
|
1006
|
+
}, "\u751F\u6210\u997C\u56FE"), /*#__PURE__*/_react.default.createElement("div", {
|
|
1007
|
+
className: "rightClickItems",
|
|
1008
|
+
onClick: function onClick() {
|
|
1009
|
+
return setChartsModalStatus('line');
|
|
1010
|
+
}
|
|
1011
|
+
}, "\u751F\u6210\u6298\u7EBF\u56FE")), chartsModalStatus && /*#__PURE__*/_react.default.createElement(_tableChartsModal.default, {
|
|
1012
|
+
type: chartsModalStatus,
|
|
1013
|
+
onCancel: function onCancel() {
|
|
1014
|
+
return setChartsModalStatus(false);
|
|
1015
|
+
},
|
|
1016
|
+
onOk: function onOk() {
|
|
1017
|
+
return setChartsModalStatus(false);
|
|
1018
|
+
},
|
|
1019
|
+
data: dataSource,
|
|
1020
|
+
columns: columns,
|
|
1021
|
+
selectInfo: (0, _lodash.pick)(shellStatusRef.current, ['start', 'end'])
|
|
1022
|
+
}));
|
|
579
1023
|
}); // 监听大小: 这里的高度是整个表格的高度,表体需要减去列头和分页的高度
|
|
580
1024
|
|
|
581
1025
|
/** 1: 使用scroll.x y 来控制宽高 默认都是100% */
|
|
@@ -584,13 +1028,13 @@ var ResizeSize = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
584
1028
|
var _props$autoSizer = props.autoSizer,
|
|
585
1029
|
autoSizer = _props$autoSizer === void 0 ? false : _props$autoSizer;
|
|
586
1030
|
|
|
587
|
-
var
|
|
1031
|
+
var _useState21 = (0, _react.useState)({
|
|
588
1032
|
width: '100%',
|
|
589
1033
|
height: '100%'
|
|
590
1034
|
}),
|
|
591
|
-
|
|
592
|
-
tableSize =
|
|
593
|
-
setTableSize =
|
|
1035
|
+
_useState22 = (0, _slicedToArray2.default)(_useState21, 2),
|
|
1036
|
+
tableSize = _useState22[0],
|
|
1037
|
+
setTableSize = _useState22[1];
|
|
594
1038
|
|
|
595
1039
|
var defaultRef = ref || (0, _react.useRef)(null);
|
|
596
1040
|
var tableWarpRef = (0, _react.useRef)(null);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface IProps {
|
|
2
|
+
value: string | number | readonly string[] | undefined;
|
|
3
|
+
onChange: (value: string | number | readonly string[] | undefined) => void;
|
|
4
|
+
onKeyDown?: (e: any) => void;
|
|
5
|
+
handleSave?: (e: any) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const InputDataEdit: (props: IProps) => JSX.Element;
|
|
8
|
+
export default InputDataEdit;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { Input } from 'linkmore-design';
|
|
3
|
+
|
|
4
|
+
var InputDataEdit = function InputDataEdit(props) {
|
|
5
|
+
var value = props.value,
|
|
6
|
+
onChange = props.onChange,
|
|
7
|
+
onKeyDown = props.onKeyDown,
|
|
8
|
+
handleSave = props.handleSave;
|
|
9
|
+
var inputRef = useRef(null);
|
|
10
|
+
useEffect(function () {
|
|
11
|
+
setTimeout(function () {
|
|
12
|
+
var _a;
|
|
13
|
+
|
|
14
|
+
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
15
|
+
}, 150);
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
18
|
+
var handleChange = function handleChange(e) {
|
|
19
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return /*#__PURE__*/React.createElement(Input, {
|
|
23
|
+
ref: inputRef,
|
|
24
|
+
className: "data-editor",
|
|
25
|
+
value: value,
|
|
26
|
+
size: 'small',
|
|
27
|
+
bordered: false,
|
|
28
|
+
onChange: handleChange,
|
|
29
|
+
onKeyDown: onKeyDown,
|
|
30
|
+
onPressEnter: handleSave,
|
|
31
|
+
onBlur: handleSave
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default InputDataEdit;
|