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