@zhenliang/sheet 0.0.1
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/core/config.js +13 -0
- package/dist/core/editor/cascaderEditor/index.js +63 -0
- package/dist/core/editor/cascaderEditor/index.less +24 -0
- package/dist/core/editor/dateEditor/index.js +42 -0
- package/dist/core/editor/dateEditor/index.less +7 -0
- package/dist/core/editor/numberEditor/index.js +25 -0
- package/dist/core/editor/numberEditor/index.less +17 -0
- package/dist/core/editor/selectEditor/index.js +44 -0
- package/dist/core/editor/selectEditor/index.less +41 -0
- package/dist/core/reducers/index.js +36 -0
- package/dist/core/reducers/keyboardReducer.js +91 -0
- package/dist/core/reducers/mouseReducer.js +151 -0
- package/dist/core/reducers/sideEffectReducer.js +324 -0
- package/dist/core/reducers/stateReducer.js +140 -0
- package/dist/core/sheet/Cell.js +160 -0
- package/dist/core/sheet/DataEditor.js +21 -0
- package/dist/core/sheet/DefaultCell.js +31 -0
- package/dist/core/sheet/DefaultRow.js +25 -0
- package/dist/core/sheet/DefaultRowMapper.js +15 -0
- package/dist/core/sheet/DefaultShell.js +12 -0
- package/dist/core/sheet/Event.js +17 -0
- package/dist/core/sheet/ValueViewer.js +9 -0
- package/dist/core/sheet/index.js +201 -0
- package/dist/core/sheet/index.less +261 -0
- package/dist/core/sheet/useCellEvent.js +22 -0
- package/dist/core/sheet/useContextMenu.js +86 -0
- package/dist/core/sheet/useKeyBoardEvent.js +44 -0
- package/dist/core/sheet/useMouseEvent.js +298 -0
- package/dist/core/sheet/useVirtualList.js +74 -0
- package/dist/core/sheet/var.less +41 -0
- package/dist/core/shell/draggableShell/index.js +182 -0
- package/dist/core/shell/draggableShell/index.less +16 -0
- package/dist/core/shell/resizeShell.js +57 -0
- package/dist/core/shell/tableShell.js +105 -0
- package/dist/core/table/index.js +311 -0
- package/dist/core/table/useGroupConfig.js +32 -0
- package/dist/core/table/useRowSelection.js +24 -0
- package/dist/core/table/util.js +29 -0
- package/dist/core/util.js +363 -0
- package/dist/core/viewer/checkViewer/index.js +23 -0
- package/dist/core/viewer/groupViewer/index.js +28 -0
- package/dist/example/basic.js +120 -0
- package/dist/example/draggable.js +0 -0
- package/dist/example/ellipsis.js +63 -0
- package/dist/example/fixed.js +88 -0
- package/dist/example/group.js +84 -0
- package/dist/example/index.less +5 -0
- package/dist/example/selection.js +85 -0
- package/dist/example/sheet.js +356 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/useEventBus.js +17 -0
- package/dist/hooks/useKeyboard.js +108 -0
- package/dist/hooks/useMiddlewareReducer.js +47 -0
- package/dist/hooks/useMouse.js +52 -0
- package/dist/hooks/useSetState.js +27 -0
- package/dist/hooks/useSheetEvent.js +5 -0
- package/dist/index.js +3 -0
- package/dist/standardUtils/index.js +32 -0
- package/dist/typings/index.d.ts +1 -0
- package/dist/typings/sheet.d.ts +209 -0
- package/dist/typings/table.js +0 -0
- package/package.json +84 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { dataSourceToRowConfig } from "./util";
|
|
9
|
+
export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig, hasChildren) {
|
|
10
|
+
var _useState = useState(),
|
|
11
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
12
|
+
groupConfig = _useState2[0],
|
|
13
|
+
setGroupConfig = _useState2[1];
|
|
14
|
+
var groupConfigRef = useRef();
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
if (!hasChildren) return;
|
|
17
|
+
var rowConfig = dataSourceToRowConfig(dataSource, tableGroupConfig === null || tableGroupConfig === void 0 ? void 0 : tableGroupConfig.defaultOpen);
|
|
18
|
+
if (groupConfigRef.current) {
|
|
19
|
+
groupConfigRef.current.groups.forEach(function (_ref, index) {
|
|
20
|
+
var _groupConfigRef$curre;
|
|
21
|
+
var groupName = _ref.groupName;
|
|
22
|
+
var rowIndex = rowConfig.groups.findIndex(function (item) {
|
|
23
|
+
return item.groupName === groupName;
|
|
24
|
+
});
|
|
25
|
+
rowConfig.groupOpen[rowIndex] = ((_groupConfigRef$curre = groupConfigRef.current) === null || _groupConfigRef$curre === void 0 ? void 0 : _groupConfigRef$curre.groupOpen[index]) || rowConfig.groupOpen[rowIndex];
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
setGroupConfig(rowConfig);
|
|
29
|
+
groupConfigRef.current = rowConfig;
|
|
30
|
+
}, [dataSource, hasChildren]);
|
|
31
|
+
return [groupConfig, setGroupConfig];
|
|
32
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useEffect, useRef, useState } from 'react';
|
|
8
|
+
export var useRowSelection = function useRowSelection(dataSource, rowSelection, hasChildren) {
|
|
9
|
+
var _dataSource$length;
|
|
10
|
+
var _useState = useState(Array((_dataSource$length = dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) !== null && _dataSource$length !== void 0 ? _dataSource$length : 0).fill(false)),
|
|
11
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
12
|
+
checkedRow = _useState2[0],
|
|
13
|
+
setCheckedRow = _useState2[1];
|
|
14
|
+
var checkedRowRef = useRef(checkedRow);
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
if (hasChildren || !rowSelection) return;
|
|
17
|
+
var currentEmpty = Array(dataSource.length).fill(false).map(function (checked, index) {
|
|
18
|
+
return checkedRowRef.current[index] ? true : false;
|
|
19
|
+
});
|
|
20
|
+
setCheckedRow(currentEmpty);
|
|
21
|
+
checkedRowRef.current = currentEmpty;
|
|
22
|
+
}, [dataSource.length, hasChildren, rowSelection]);
|
|
23
|
+
return [checkedRow, setCheckedRow];
|
|
24
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export var dataSourceToRowConfig = function dataSourceToRowConfig(dataSource) {
|
|
2
|
+
var defaultOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
3
|
+
var groups = [];
|
|
4
|
+
var groupOpen = [];
|
|
5
|
+
if (!(dataSource !== null && dataSource !== void 0 && dataSource.length)) return {
|
|
6
|
+
groups: groups,
|
|
7
|
+
groupOpen: groupOpen
|
|
8
|
+
};
|
|
9
|
+
var currentIndex = 0;
|
|
10
|
+
dataSource.forEach(function (item, index) {
|
|
11
|
+
var _ref = item,
|
|
12
|
+
children = _ref.children;
|
|
13
|
+
if ((children === null || children === void 0 ? void 0 : children.length) > 0) {
|
|
14
|
+
groups.push({
|
|
15
|
+
groupStart: currentIndex,
|
|
16
|
+
groupEnd: currentIndex + children.length + 1,
|
|
17
|
+
// 默认 key 或者 id 是行数据的唯一标识
|
|
18
|
+
groupName: "".concat(item.key || item.id || index, "group")
|
|
19
|
+
});
|
|
20
|
+
currentIndex += children.length;
|
|
21
|
+
groupOpen.push(defaultOpen);
|
|
22
|
+
}
|
|
23
|
+
currentIndex++;
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
groups: groups,
|
|
27
|
+
groupOpen: groupOpen
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
+
/* eslint-disable no-param-reassign */
|
|
14
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
15
|
+
import { cloneDeep, isNil, range } from 'lodash';
|
|
16
|
+
export function findParentTd(el) {
|
|
17
|
+
if (!el) return null;
|
|
18
|
+
if (el.tagName === 'TD') return el;
|
|
19
|
+
return findParentTd(el.parentElement);
|
|
20
|
+
}
|
|
21
|
+
export function extractDataRowAndCol(el) {
|
|
22
|
+
var row = Number(el.getAttribute('data-row'));
|
|
23
|
+
var col = Number(el.getAttribute('data-col'));
|
|
24
|
+
return {
|
|
25
|
+
row: row,
|
|
26
|
+
col: col
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function getRowColConfig(start, end) {
|
|
30
|
+
var _start$row, _end$row, _start$row2, _end$row2, _start$col, _end$col, _start$col2, _end$col2;
|
|
31
|
+
var startRow = Math.min((_start$row = start === null || start === void 0 ? void 0 : start.row) !== null && _start$row !== void 0 ? _start$row : -1, (_end$row = end === null || end === void 0 ? void 0 : end.row) !== null && _end$row !== void 0 ? _end$row : -1);
|
|
32
|
+
var endRow = Math.max((_start$row2 = start === null || start === void 0 ? void 0 : start.row) !== null && _start$row2 !== void 0 ? _start$row2 : -1, (_end$row2 = end === null || end === void 0 ? void 0 : end.row) !== null && _end$row2 !== void 0 ? _end$row2 : -1);
|
|
33
|
+
var startCol = Math.min((_start$col = start === null || start === void 0 ? void 0 : start.col) !== null && _start$col !== void 0 ? _start$col : -1, (_end$col = end === null || end === void 0 ? void 0 : end.col) !== null && _end$col !== void 0 ? _end$col : -1);
|
|
34
|
+
var endCol = Math.max((_start$col2 = start === null || start === void 0 ? void 0 : start.col) !== null && _start$col2 !== void 0 ? _start$col2 : -1, (_end$col2 = end === null || end === void 0 ? void 0 : end.col) !== null && _end$col2 !== void 0 ? _end$col2 : -1);
|
|
35
|
+
return {
|
|
36
|
+
startRow: startRow,
|
|
37
|
+
endRow: endRow,
|
|
38
|
+
startCol: startCol,
|
|
39
|
+
endCol: endCol
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function flatRowColIndex(start, end) {
|
|
43
|
+
var _getRowColConfig = getRowColConfig(start, end),
|
|
44
|
+
startRow = _getRowColConfig.startRow,
|
|
45
|
+
endRow = _getRowColConfig.endRow,
|
|
46
|
+
startCol = _getRowColConfig.startCol,
|
|
47
|
+
endCol = _getRowColConfig.endCol;
|
|
48
|
+
if ([startRow, endRow, startCol, endCol].some(function (a) {
|
|
49
|
+
return a === -1;
|
|
50
|
+
})) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
var cellList = [];
|
|
54
|
+
for (var i = startRow; i <= endRow; i++) {
|
|
55
|
+
for (var j = startCol; j <= endCol; j++) {
|
|
56
|
+
cellList.push({
|
|
57
|
+
row: i,
|
|
58
|
+
col: j
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return cellList;
|
|
63
|
+
}
|
|
64
|
+
export function flatRowCol(start, end) {
|
|
65
|
+
var rowColIndex = flatRowColIndex(start, end);
|
|
66
|
+
return rowColIndex.map(function (_ref) {
|
|
67
|
+
var row = _ref.row,
|
|
68
|
+
col = _ref.col;
|
|
69
|
+
return "".concat(row, "-").concat(col);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export function isInputKey(keyCode) {
|
|
73
|
+
var numbersPressed = keyCode >= 48 && keyCode <= 57;
|
|
74
|
+
var lettersPressed = keyCode >= 65 && keyCode <= 90;
|
|
75
|
+
var latin1Supplement = keyCode >= 160 && keyCode <= 255;
|
|
76
|
+
var numPadKeysPressed = keyCode >= 96 && keyCode <= 105;
|
|
77
|
+
var equationKeysPressed = [187 /* equal */, 189 /* substract */, 190 /* period */, 107 /* add */, 109 /* decimal point */, 110].indexOf(keyCode) > -1;
|
|
78
|
+
return numPadKeysPressed || numbersPressed || lettersPressed || latin1Supplement || equationKeysPressed;
|
|
79
|
+
}
|
|
80
|
+
export function classNames() {
|
|
81
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
82
|
+
args[_key] = arguments[_key];
|
|
83
|
+
}
|
|
84
|
+
return args.filter(Boolean).join(' ');
|
|
85
|
+
}
|
|
86
|
+
export function stringToClipboardData(str) {
|
|
87
|
+
// navigator.clipboard.writeText(str);
|
|
88
|
+
navigator.clipboard.writeText(str).then(function () {
|
|
89
|
+
console.log('复制成功');
|
|
90
|
+
}, function () {
|
|
91
|
+
console.error('复制失败');
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export var defaultParsePaste = function defaultParsePaste(str) {
|
|
95
|
+
return str.split(/\r\n|\n|\r/).map(function (row) {
|
|
96
|
+
return row.split('\t');
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
export function clipboardDataToString() {
|
|
100
|
+
return new Promise(function (resolve) {
|
|
101
|
+
navigator.clipboard.readText().then(function (res) {
|
|
102
|
+
resolve(defaultParsePaste(res));
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
export function formatDataToCell(_ref2) {
|
|
107
|
+
var _start$row3, _end$row3;
|
|
108
|
+
var start = _ref2.start,
|
|
109
|
+
editing = _ref2.editing,
|
|
110
|
+
end = _ref2.end,
|
|
111
|
+
data = _ref2.data,
|
|
112
|
+
pasteData = _ref2.pasteData,
|
|
113
|
+
groupConfig = _ref2.groupConfig,
|
|
114
|
+
_ref2$freePaste = _ref2.freePaste,
|
|
115
|
+
freePaste = _ref2$freePaste === void 0 ? false : _ref2$freePaste;
|
|
116
|
+
if (editing || !data) return;
|
|
117
|
+
var cells = flatRowColIndex(start, end);
|
|
118
|
+
if (!cells.length) return;
|
|
119
|
+
var rowCount = cells[cells.length - 1].row - cells[0].row + 1;
|
|
120
|
+
if (!cells.length) return;
|
|
121
|
+
var isMultiCells = cells.length > 1;
|
|
122
|
+
var isSinglePaste = pasteData.length === 1 && pasteData[0].length === 1;
|
|
123
|
+
|
|
124
|
+
// todo 超出行的处理
|
|
125
|
+
var isExRow = cells[cells.length - 1].row > ((data === null || data === void 0 ? void 0 : data.length) || 0);
|
|
126
|
+
var groupMap = groupConfigToGroupMap(groupConfig);
|
|
127
|
+
var actualRowCount = range((_start$row3 = start === null || start === void 0 ? void 0 : start.row) !== null && _start$row3 !== void 0 ? _start$row3 : 0, ((_end$row3 = end === null || end === void 0 ? void 0 : end.row) !== null && _end$row3 !== void 0 ? _end$row3 : 0) + 1).reduce(function (left, index) {
|
|
128
|
+
var _groupMap$get, _groupMap$get2;
|
|
129
|
+
if (groupMap.get(index) && !((_groupMap$get = groupMap.get(index)) !== null && _groupMap$get !== void 0 && _groupMap$get.isStart) && !((_groupMap$get2 = groupMap.get(index)) !== null && _groupMap$get2 !== void 0 && _groupMap$get2.isOpen)) {
|
|
130
|
+
return left;
|
|
131
|
+
}
|
|
132
|
+
return left + 1;
|
|
133
|
+
}, 0);
|
|
134
|
+
var changes = [];
|
|
135
|
+
if (isMultiCells && isSinglePaste) {
|
|
136
|
+
// 选中多个单元格,粘贴单个数据
|
|
137
|
+
cells.forEach(function (_ref3) {
|
|
138
|
+
var _groupMap$get3, _groupMap$get4;
|
|
139
|
+
var row = _ref3.row,
|
|
140
|
+
col = _ref3.col;
|
|
141
|
+
if (data[row][col].readonly) return;
|
|
142
|
+
if (groupMap.get(row) && !((_groupMap$get3 = groupMap.get(row)) !== null && _groupMap$get3 !== void 0 && _groupMap$get3.isStart) && !((_groupMap$get4 = groupMap.get(row)) !== null && _groupMap$get4 !== void 0 && _groupMap$get4.isOpen)) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
changes.push({
|
|
146
|
+
row: row,
|
|
147
|
+
col: col,
|
|
148
|
+
value: pasteData[0][0]
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
changes: changes
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (!isMultiCells) {
|
|
156
|
+
// 选中单个单元格
|
|
157
|
+
var _cells$ = cells[0],
|
|
158
|
+
row = _cells$.row,
|
|
159
|
+
col = _cells$.col;
|
|
160
|
+
var extChanges = [];
|
|
161
|
+
var hasStartAndNotOpen = false;
|
|
162
|
+
pasteData.forEach(function (rowData, i) {
|
|
163
|
+
rowData.forEach(function (cell, j) {
|
|
164
|
+
if (row + i >= data.length) {
|
|
165
|
+
extChanges.push({
|
|
166
|
+
row: row + i,
|
|
167
|
+
col: col + j,
|
|
168
|
+
value: pasteData[i][j]
|
|
169
|
+
});
|
|
170
|
+
} else {
|
|
171
|
+
var _data, _data2, _groupMap$get5, _groupMap$get6;
|
|
172
|
+
if (data !== null && data !== void 0 && (_data = data[row + i]) !== null && _data !== void 0 && (_data2 = _data[col + j]) !== null && _data2 !== void 0 && _data2.readonly) return;
|
|
173
|
+
if (groupMap.get(row + i) && !((_groupMap$get5 = groupMap.get(row + i)) !== null && _groupMap$get5 !== void 0 && _groupMap$get5.isStart) && !((_groupMap$get6 = groupMap.get(row + i)) !== null && _groupMap$get6 !== void 0 && _groupMap$get6.isOpen)) {
|
|
174
|
+
hasStartAndNotOpen = true;
|
|
175
|
+
}
|
|
176
|
+
changes.push({
|
|
177
|
+
row: row + i,
|
|
178
|
+
col: col + j,
|
|
179
|
+
value: pasteData[i][j]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
if (hasStartAndNotOpen) {
|
|
185
|
+
console.error('有折叠单元格,不可粘贴');
|
|
186
|
+
return {
|
|
187
|
+
changes: [],
|
|
188
|
+
extChanges: []
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
changes: changes,
|
|
193
|
+
extChanges: isExRow && freePaste ? extChanges : undefined
|
|
194
|
+
};
|
|
195
|
+
} else {
|
|
196
|
+
// 选中多个单元格,粘贴多个数据
|
|
197
|
+
if (actualRowCount !== pasteData.length || cells.length / rowCount * actualRowCount !== pasteData.length * pasteData[0].length) {
|
|
198
|
+
// 单元格数量不对
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
var baseCol = cells[0].col;
|
|
202
|
+
var pasteCount = 0;
|
|
203
|
+
cells.forEach(function (_ref4) {
|
|
204
|
+
var _groupMap$get7, _groupMap$get8;
|
|
205
|
+
var row = _ref4.row,
|
|
206
|
+
col = _ref4.col;
|
|
207
|
+
if (data[row][col].readonly) return;
|
|
208
|
+
if (groupMap.get(row) && !((_groupMap$get7 = groupMap.get(row)) !== null && _groupMap$get7 !== void 0 && _groupMap$get7.isStart) && !((_groupMap$get8 = groupMap.get(row)) !== null && _groupMap$get8 !== void 0 && _groupMap$get8.isOpen)) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
changes.push({
|
|
212
|
+
row: row,
|
|
213
|
+
col: col,
|
|
214
|
+
value: pasteData[pasteCount++][col - baseCol]
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
return {
|
|
218
|
+
changes: changes
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
export var defaultValueRenderer = function defaultValueRenderer(cell) {
|
|
223
|
+
return cell.value;
|
|
224
|
+
};
|
|
225
|
+
export function renderValue(cell) {
|
|
226
|
+
var value = defaultValueRenderer(cell);
|
|
227
|
+
return value === null || typeof value === 'undefined' ? '' : value;
|
|
228
|
+
}
|
|
229
|
+
export var optionsTransferToValue = function optionsTransferToValue(options, val) {
|
|
230
|
+
var values = [];
|
|
231
|
+
for (var i = 0; i < options.length; i++) {
|
|
232
|
+
var _options$i = options[i],
|
|
233
|
+
label = _options$i.label,
|
|
234
|
+
value = _options$i.value,
|
|
235
|
+
children = _options$i.children;
|
|
236
|
+
if (children) {
|
|
237
|
+
values = optionsTransferToValue(children, val);
|
|
238
|
+
if (values.length) {
|
|
239
|
+
values = [value].concat(_toConsumableArray(values));
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
} else if (label === val) {
|
|
243
|
+
values.push(value);
|
|
244
|
+
break;
|
|
245
|
+
} else {
|
|
246
|
+
values = [];
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return values;
|
|
250
|
+
};
|
|
251
|
+
export var groupConfigToGroupMap = function groupConfigToGroupMap(rowGroupConfig) {
|
|
252
|
+
var _rowGroupConfig$group;
|
|
253
|
+
var groupMap = new Map();
|
|
254
|
+
if (!rowGroupConfig || !((_rowGroupConfig$group = rowGroupConfig.groups) !== null && _rowGroupConfig$group !== void 0 && _rowGroupConfig$group.length)) return groupMap;
|
|
255
|
+
var groups = rowGroupConfig.groups;
|
|
256
|
+
groups === null || groups === void 0 ? void 0 : groups.forEach(function (group, index) {
|
|
257
|
+
var groupStart = group.groupStart,
|
|
258
|
+
groupEnd = group.groupEnd;
|
|
259
|
+
for (var i = groupStart; i <= groupEnd; i++) {
|
|
260
|
+
groupMap.set(i, _objectSpread(_objectSpread({}, group), {}, {
|
|
261
|
+
isStart: i === groupStart,
|
|
262
|
+
isOpen: rowGroupConfig.groupOpen[index]
|
|
263
|
+
}));
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
return groupMap;
|
|
267
|
+
};
|
|
268
|
+
export var changeGroupConfig = function changeGroupConfig(rowGroupConfig, changeInfo) {
|
|
269
|
+
var groupMap = groupConfigToGroupMap(rowGroupConfig);
|
|
270
|
+
if (!groupMap.size) return rowGroupConfig;
|
|
271
|
+
var newGroups = cloneDeep(rowGroupConfig.groups);
|
|
272
|
+
// 顺序是先增后减
|
|
273
|
+
var add = changeInfo.add,
|
|
274
|
+
remove = changeInfo.remove;
|
|
275
|
+
if (!isNil(add)) {
|
|
276
|
+
for (var i = 0; i < newGroups.length; i++) {
|
|
277
|
+
var _newGroups$i = newGroups[i],
|
|
278
|
+
groupStart = _newGroups$i.groupStart,
|
|
279
|
+
groupEnd = _newGroups$i.groupEnd;
|
|
280
|
+
if (groupStart >= add) {
|
|
281
|
+
newGroups[i].groupStart++;
|
|
282
|
+
newGroups[i].groupEnd++;
|
|
283
|
+
} else if (groupStart < add && groupEnd >= add) {
|
|
284
|
+
newGroups[i].groupEnd++;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (!isNil(remove)) {
|
|
289
|
+
for (var _i = 0; _i < newGroups.length; _i++) {
|
|
290
|
+
var _newGroups$_i = newGroups[_i],
|
|
291
|
+
_groupStart = _newGroups$_i.groupStart,
|
|
292
|
+
_groupEnd = _newGroups$_i.groupEnd;
|
|
293
|
+
if (_groupStart > remove) {
|
|
294
|
+
newGroups[_i].groupStart--;
|
|
295
|
+
newGroups[_i].groupEnd--;
|
|
296
|
+
} else if (_groupStart <= remove && _groupEnd > remove) {
|
|
297
|
+
newGroups[_i].groupEnd--;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return _objectSpread(_objectSpread({}, rowGroupConfig), {}, {
|
|
302
|
+
groups: newGroups
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
export var rowToActualRow = function rowToActualRow(row, groupConfig) {
|
|
306
|
+
var groupMap = groupConfigToGroupMap(groupConfig);
|
|
307
|
+
if (!groupMap.size) return row;
|
|
308
|
+
groupMap.forEach(function (item, index) {
|
|
309
|
+
if (index <= row && !(item !== null && item !== void 0 && item.isOpen) && !(item !== null && item !== void 0 && item.isStart)) {
|
|
310
|
+
row--;
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
return row;
|
|
314
|
+
};
|
|
315
|
+
export var getRowHeight = function getRowHeight(container) {
|
|
316
|
+
var _container$getElement, _container$getElement2;
|
|
317
|
+
var h = ((_container$getElement = container.getElementsByTagName('td')[0]) === null || _container$getElement === void 0 ? void 0 : (_container$getElement2 = _container$getElement.parentNode) === null || _container$getElement2 === void 0 ? void 0 : _container$getElement2.clientHeight) || 30;
|
|
318
|
+
return h;
|
|
319
|
+
};
|
|
320
|
+
export var getNextVisibleRow = function getNextVisibleRow(row, maxRow, groupMap) {
|
|
321
|
+
var _groupMap$get9, _groupMap$get10;
|
|
322
|
+
if (!(groupMap !== null && groupMap !== void 0 && groupMap.size)) {
|
|
323
|
+
return row;
|
|
324
|
+
}
|
|
325
|
+
if (row > maxRow) {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
if (groupMap.get(row) && !((_groupMap$get9 = groupMap.get(row)) !== null && _groupMap$get9 !== void 0 && _groupMap$get9.isOpen) && !((_groupMap$get10 = groupMap.get(row)) !== null && _groupMap$get10 !== void 0 && _groupMap$get10.isStart)) {
|
|
329
|
+
return getNextVisibleRow(row + 1, maxRow, groupMap);
|
|
330
|
+
}
|
|
331
|
+
return row;
|
|
332
|
+
};
|
|
333
|
+
export var calcMenuPosition = function calcMenuPosition(_ref5) {
|
|
334
|
+
var _menuElement$getBound, _tableElement$getBoun;
|
|
335
|
+
var tableElement = _ref5.tableElement,
|
|
336
|
+
menuElement = _ref5.menuElement,
|
|
337
|
+
x = _ref5.x,
|
|
338
|
+
y = _ref5.y;
|
|
339
|
+
var top = y;
|
|
340
|
+
var left = x;
|
|
341
|
+
var _ref6 = (_menuElement$getBound = menuElement === null || menuElement === void 0 ? void 0 : menuElement.getBoundingClientRect()) !== null && _menuElement$getBound !== void 0 ? _menuElement$getBound : {},
|
|
342
|
+
menuRight = _ref6.right,
|
|
343
|
+
menuBottom = _ref6.bottom;
|
|
344
|
+
// 这里不考虑 左边和上边 因为 屏幕连一个 menu都发不下的情况应该特殊处理
|
|
345
|
+
var _ref7 = (_tableElement$getBoun = tableElement === null || tableElement === void 0 ? void 0 : tableElement.getBoundingClientRect()) !== null && _tableElement$getBoun !== void 0 ? _tableElement$getBoun : {},
|
|
346
|
+
tableBottom = _ref7.bottom,
|
|
347
|
+
tableRight = _ref7.right;
|
|
348
|
+
var _document$body = document.body,
|
|
349
|
+
clientHeight = _document$body.clientHeight,
|
|
350
|
+
clientWidth = _document$body.clientWidth;
|
|
351
|
+
var edgeRight = Math.min(tableRight, clientWidth);
|
|
352
|
+
var edgeBottom = Math.min(tableBottom, clientHeight);
|
|
353
|
+
if (menuRight > edgeRight) {
|
|
354
|
+
left = left - (menuRight - edgeRight);
|
|
355
|
+
}
|
|
356
|
+
if (menuBottom > edgeBottom) {
|
|
357
|
+
top = top - (menuBottom - edgeBottom);
|
|
358
|
+
}
|
|
359
|
+
return {
|
|
360
|
+
top: top,
|
|
361
|
+
left: left
|
|
362
|
+
};
|
|
363
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useSheetEvent } from "../../../hooks";
|
|
2
|
+
import { Checkbox } from 'antd';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export var CheckViewer = function CheckViewer(props) {
|
|
6
|
+
var value = props.value,
|
|
7
|
+
row = props.row,
|
|
8
|
+
record = props.record;
|
|
9
|
+
var eventBus = useSheetEvent();
|
|
10
|
+
var handleChange = useCallback(function () {
|
|
11
|
+
if (!eventBus) return;
|
|
12
|
+
if (record !== null && record !== void 0 && record.isHeader) {
|
|
13
|
+
eventBus.emit('row-select-title', record !== null && record !== void 0 && record.indeterminate ? false : true);
|
|
14
|
+
} else {
|
|
15
|
+
eventBus.emit('row-select', row);
|
|
16
|
+
}
|
|
17
|
+
}, [eventBus, row, record, value]);
|
|
18
|
+
return /*#__PURE__*/_jsx(Checkbox, {
|
|
19
|
+
indeterminate: record === null || record === void 0 ? void 0 : record.indeterminate,
|
|
20
|
+
checked: value,
|
|
21
|
+
onChange: handleChange
|
|
22
|
+
});
|
|
23
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MinusSquareOutlined, PlusSquareOutlined } from '@ant-design/icons';
|
|
2
|
+
import { useSheetEvent } from "../../../hooks";
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export var GroupViewer = function GroupViewer(props) {
|
|
6
|
+
var value = props.value,
|
|
7
|
+
row = props.row,
|
|
8
|
+
record = props.record;
|
|
9
|
+
var eventBus = useSheetEvent();
|
|
10
|
+
var handleChange = useCallback(function () {
|
|
11
|
+
if (!eventBus) return;
|
|
12
|
+
if (record !== null && record !== void 0 && record.isHeader) {
|
|
13
|
+
eventBus.emit('group-open-title', !(record !== null && record !== void 0 && record.open));
|
|
14
|
+
} else {
|
|
15
|
+
eventBus.emit('group-open', {
|
|
16
|
+
row: row,
|
|
17
|
+
open: record === null || record === void 0 ? void 0 : record.open
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}, [eventBus, row, record === null || record === void 0 ? void 0 : record.open]);
|
|
21
|
+
if (value) {
|
|
22
|
+
return /*#__PURE__*/_jsx("span", {
|
|
23
|
+
onClick: handleChange,
|
|
24
|
+
children: !(record !== null && record !== void 0 && record.open) ? /*#__PURE__*/_jsx(PlusSquareOutlined, {}) : /*#__PURE__*/_jsx(MinusSquareOutlined, {})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return /*#__PURE__*/_jsx("span", {});
|
|
28
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
15
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
import Table from "../core/table";
|
|
18
|
+
import { Space, Tag } from 'antd';
|
|
19
|
+
import 'antd/dist/antd.css';
|
|
20
|
+
import React, { useCallback, useState } from 'react';
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
23
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
var columns = [{
|
|
25
|
+
title: 'Name',
|
|
26
|
+
dataIndex: 'name',
|
|
27
|
+
key: 'name',
|
|
28
|
+
editable: false,
|
|
29
|
+
render: function render(_ref) {
|
|
30
|
+
var value = _ref.value;
|
|
31
|
+
return /*#__PURE__*/_jsx("a", {
|
|
32
|
+
children: value
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
title: 'Age',
|
|
37
|
+
dataIndex: 'age',
|
|
38
|
+
key: 'age'
|
|
39
|
+
}, {
|
|
40
|
+
title: 'Address',
|
|
41
|
+
editable: false,
|
|
42
|
+
dataIndex: 'address',
|
|
43
|
+
key: 'address'
|
|
44
|
+
}, {
|
|
45
|
+
title: 'Tags',
|
|
46
|
+
key: 'tags',
|
|
47
|
+
dataIndex: 'tags',
|
|
48
|
+
render: function render(_ref2) {
|
|
49
|
+
var tags = _ref2.record.tags;
|
|
50
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
51
|
+
children: tags === null || tags === void 0 ? void 0 : tags.map(function (tag) {
|
|
52
|
+
var color = tag.length > 5 ? 'geekblue' : 'green';
|
|
53
|
+
if (tag === 'loser') {
|
|
54
|
+
color = 'volcano';
|
|
55
|
+
}
|
|
56
|
+
return /*#__PURE__*/_jsx(Tag, {
|
|
57
|
+
color: color,
|
|
58
|
+
children: tag.toUpperCase()
|
|
59
|
+
}, tag);
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
title: 'Action',
|
|
65
|
+
key: 'action',
|
|
66
|
+
editable: false,
|
|
67
|
+
render: function render(_ref3) {
|
|
68
|
+
var record = _ref3.record;
|
|
69
|
+
return /*#__PURE__*/_jsxs(Space, {
|
|
70
|
+
size: "middle",
|
|
71
|
+
children: [/*#__PURE__*/_jsxs("a", {
|
|
72
|
+
children: ["Invite ", record.name]
|
|
73
|
+
}), /*#__PURE__*/_jsx("a", {
|
|
74
|
+
children: "Delete"
|
|
75
|
+
})]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}];
|
|
79
|
+
var data = [{
|
|
80
|
+
key: '1',
|
|
81
|
+
name: 'John Brown',
|
|
82
|
+
age: 32,
|
|
83
|
+
address: 'New York No. 1 Lake Park',
|
|
84
|
+
tags: ['nice', 'developer']
|
|
85
|
+
}, {
|
|
86
|
+
key: '2',
|
|
87
|
+
name: 'Jim Green',
|
|
88
|
+
age: 42,
|
|
89
|
+
address: 'London No. 1 Lake Park',
|
|
90
|
+
tags: ['loser']
|
|
91
|
+
}, {
|
|
92
|
+
key: '3',
|
|
93
|
+
name: 'Joe Black',
|
|
94
|
+
age: 32,
|
|
95
|
+
address: 'Sidney No. 1 Lake Park',
|
|
96
|
+
tags: ['cool', 'teacher']
|
|
97
|
+
}];
|
|
98
|
+
var App = function App() {
|
|
99
|
+
var _useState = useState(data),
|
|
100
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
101
|
+
dataSource = _useState2[0],
|
|
102
|
+
setData = _useState2[1];
|
|
103
|
+
var onChange = useCallback(function (changes) {
|
|
104
|
+
var newData = _toConsumableArray(dataSource);
|
|
105
|
+
changes.forEach(function (_ref4) {
|
|
106
|
+
var _String;
|
|
107
|
+
var row = _ref4.row,
|
|
108
|
+
key = _ref4.key,
|
|
109
|
+
value = _ref4.value;
|
|
110
|
+
newData[row] = _objectSpread(_objectSpread({}, newData[row]), {}, _defineProperty({}, key, key === 'tags' ? (_String = String(value)) === null || _String === void 0 ? void 0 : _String.split(',') : value));
|
|
111
|
+
});
|
|
112
|
+
setData(newData);
|
|
113
|
+
}, [dataSource]);
|
|
114
|
+
return /*#__PURE__*/_jsx(Table, {
|
|
115
|
+
columns: columns,
|
|
116
|
+
dataSource: dataSource,
|
|
117
|
+
onChange: onChange
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
export default App;
|
|
File without changes
|