@zhenliang/sheet 0.1.73 → 0.1.74
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/core/editor/dateEditor/index.js +6 -6
- package/dist/core/editor/numberEditor/index.d.ts +1 -1
- package/dist/core/editor/numberEditor/index.js +7 -7
- package/dist/core/editor/selectEditor/index.js +6 -6
- package/dist/core/reducers/index.d.ts +2 -2
- package/dist/core/reducers/keyboardReducer.js +8 -7
- package/dist/core/reducers/mouseReducer.js +10 -9
- package/dist/core/reducers/sideEffectReducer.d.ts +1 -1
- package/dist/core/reducers/sideEffectReducer.js +17 -17
- package/dist/core/reducers/stateReducer.js +10 -10
- package/dist/core/sheet/Cell.js +2 -2
- package/dist/core/sheet/DataEditor.js +1 -1
- package/dist/core/sheet/DefaultCell.d.ts +4 -3
- package/dist/core/sheet/DefaultCell.js +5 -5
- package/dist/core/sheet/DefaultRowMapper.js +5 -5
- package/dist/core/sheet/Remark.d.ts +9 -0
- package/dist/core/sheet/Remark.js +32 -0
- package/dist/core/sheet/index.js +67 -19
- package/dist/core/sheet/index.less +36 -0
- package/dist/core/sheet/searchInput.js +1 -1
- package/dist/core/sheet/useContextMenu.d.ts +1 -1
- package/dist/core/sheet/useContextMenu.js +11 -11
- package/dist/core/sheet/useKeyBoardEvent.js +1 -1
- package/dist/core/sheet/useMouseEvent.js +11 -12
- package/dist/core/sheet/useRemarkContainer.d.ts +14 -0
- package/dist/core/sheet/useRemarkContainer.js +144 -0
- package/dist/core/sheet/useSearchInput.js +8 -8
- package/dist/core/sheet/useSelectVisible.js +3 -3
- package/dist/core/sheet/useVirtualList.js +3 -3
- package/dist/core/shell/draggableShell/index.d.ts +2 -1
- package/dist/core/shell/draggableShell/index.js +15 -10
- package/dist/core/shell/tableShell.d.ts +3 -2
- package/dist/core/shell/tableShell.js +11 -155
- package/dist/core/table/addButton.d.ts +0 -1
- package/dist/core/table/addButton.js +2 -3
- package/dist/core/table/events.js +7 -7
- package/dist/core/table/index.d.ts +1 -0
- package/dist/core/table/index.js +167 -17
- package/dist/core/table/index.less +19 -0
- package/dist/core/table/remarkEvent.d.ts +5 -0
- package/dist/core/table/remarkEvent.js +9 -0
- package/dist/core/table/useGroupConfig.d.ts +1 -1
- package/dist/core/table/useGroupConfig.js +16 -14
- package/dist/core/table/useRowSelection.d.ts +3 -25
- package/dist/core/table/useRowSelection.js +7 -4
- package/dist/core/util.js +14 -14
- package/dist/core/viewer/editViewer/index.js +1 -2
- package/dist/core/viewer/groupViewer/index.js +4 -8
- package/dist/example/antComponent.js +9 -9
- package/dist/example/basic.js +6 -6
- package/dist/example/group.js +1 -2
- package/dist/example/selection.js +6 -6
- package/dist/example/sheet.js +16 -21
- package/dist/example/valuationAnalyze.d.ts +1 -0
- package/dist/example/valuationAnalyze.js +356 -14
- package/dist/hooks/useEventBus.d.ts +1 -0
- package/dist/hooks/useEventBus.js +1 -1
- package/dist/hooks/useKeyboard.d.ts +2 -2
- package/dist/hooks/useMiddlewareReducer.d.ts +5 -5
- package/dist/hooks/useMiddlewareReducer.js +2 -2
- package/dist/hooks/useMouse.d.ts +1 -1
- package/dist/hooks/useMouse.js +6 -6
- package/dist/hooks/useSetState.js +6 -6
- package/dist/standardUtils/index.d.ts +1 -1
- package/dist/standardUtils/index.js +1 -1
- package/dist/type/sheet.d.ts +40 -32
- package/dist/type/sheetTable.d.ts +24 -11
- package/package.json +8 -3
- package/changes.md +0 -45
package/dist/core/table/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
function _typeof(
|
|
2
|
-
var _excluded = ["sheetInstance", "columns", "dataSource", "rowKey", "rowSelection", "groupConfig", "onChange", "handleAdd", "handleBatchAdd", "draggable", "eventHandler"];
|
|
3
|
-
function ownKeys(
|
|
4
|
-
function _objectSpread(
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["sheetInstance", "columns", "dataSource", "rowKey", "rowSelection", "groupConfig", "onChange", "handleAdd", "handleBatchAdd", "draggable", "eventHandler", "remarkRender", "handleAddRemark", "showRemark", "freeze"];
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
5
|
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; }
|
|
6
|
-
function _toPropertyKey(
|
|
7
|
-
function _toPrimitive(
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
8
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
9
|
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."); }
|
|
10
10
|
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); }
|
|
11
11
|
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; }
|
|
12
|
-
function _iterableToArrayLimit(
|
|
12
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
13
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
14
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
15
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -17,12 +17,14 @@ import { Sheet, useSetState } from "../..";
|
|
|
17
17
|
import { GroupContext } from "../../hooks/useGroupConfig";
|
|
18
18
|
import { WidthContext } from "../../hooks/useWidthConfig";
|
|
19
19
|
import { ConfigProvider, Empty } from 'antd';
|
|
20
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
20
|
+
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
21
21
|
import { SheetEvent } from "../sheet/Event";
|
|
22
22
|
import { DraggableShell } from "../shell/draggableShell";
|
|
23
23
|
import { TableShell } from "../shell/tableShell";
|
|
24
24
|
import { AddButton } from "./addButton";
|
|
25
25
|
import { GroupEvent, SelectionEvent } from "./events";
|
|
26
|
+
import "./index.less";
|
|
27
|
+
import { RemarkEvent } from "./remarkEvent";
|
|
26
28
|
import { formatGroupData, useGroupConfig } from "./useGroupConfig";
|
|
27
29
|
import { formatSelectionData, useRowSelection } from "./useRowSelection";
|
|
28
30
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -39,6 +41,12 @@ var Table = function Table(_ref) {
|
|
|
39
41
|
handleBatchAdd = _ref.handleBatchAdd,
|
|
40
42
|
draggable = _ref.draggable,
|
|
41
43
|
eventHandler = _ref.eventHandler,
|
|
44
|
+
RemarkRender = _ref.remarkRender,
|
|
45
|
+
handleAddRemark = _ref.handleAddRemark,
|
|
46
|
+
_ref$showRemark = _ref.showRemark,
|
|
47
|
+
showRemark = _ref$showRemark === void 0 ? false : _ref$showRemark,
|
|
48
|
+
_ref$freeze = _ref.freeze,
|
|
49
|
+
freeze = _ref$freeze === void 0 ? false : _ref$freeze,
|
|
42
50
|
args = _objectWithoutProperties(_ref, _excluded);
|
|
43
51
|
var _useState = useState([[]]),
|
|
44
52
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -49,15 +57,52 @@ var Table = function Table(_ref) {
|
|
|
49
57
|
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
50
58
|
widths = _useSetState2[0],
|
|
51
59
|
setWidth = _useSetState2[1];
|
|
52
|
-
var sheetInstance =
|
|
60
|
+
var sheetInstance = _sheetInstance;
|
|
53
61
|
var dataHasChildren = dataSource === null || dataSource === void 0 ? void 0 : dataSource.some(function (item) {
|
|
54
62
|
var _item$children;
|
|
55
|
-
return (item === null || item === void 0
|
|
63
|
+
return (item === null || item === void 0 || (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) > 0;
|
|
56
64
|
});
|
|
57
65
|
var configWithChildren = !!groupConfig && !!dataSource.length;
|
|
58
66
|
var hasChildren = dataHasChildren || configWithChildren;
|
|
59
67
|
var hasControl = hasChildren || !!rowSelection;
|
|
60
68
|
var offset = hasControl ? 2 : 1;
|
|
69
|
+
useImperativeHandle(sheetRef, function () {
|
|
70
|
+
return new Proxy({}, {
|
|
71
|
+
get: function get(target, property) {
|
|
72
|
+
var _sheetInstance$curren4;
|
|
73
|
+
if (property === 'goToByTable') {
|
|
74
|
+
var goToByTable = function goToByTable(id, columnKey, currentData) {
|
|
75
|
+
var _currentData$, _sheetInstance$curren, _sheetInstance$curren2;
|
|
76
|
+
var toCol = currentData === null || currentData === void 0 || (_currentData$ = currentData[0]) === null || _currentData$ === void 0 ? void 0 : _currentData$.findIndex(function (d) {
|
|
77
|
+
return d.dataIndex === columnKey;
|
|
78
|
+
});
|
|
79
|
+
var toRow = currentData.findIndex(function (d) {
|
|
80
|
+
return String(d === null || d === void 0 ? void 0 : d[0].id) === String(id);
|
|
81
|
+
});
|
|
82
|
+
(_sheetInstance$curren = sheetInstance.current) === null || _sheetInstance$curren === void 0 || _sheetInstance$curren.goTo(toRow, toCol);
|
|
83
|
+
(_sheetInstance$curren2 = sheetInstance.current) === null || _sheetInstance$curren2 === void 0 || _sheetInstance$curren2.select({
|
|
84
|
+
start: {
|
|
85
|
+
row: toRow,
|
|
86
|
+
col: toCol
|
|
87
|
+
},
|
|
88
|
+
end: {
|
|
89
|
+
row: toRow,
|
|
90
|
+
col: toCol
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
return function () {
|
|
95
|
+
var _sheetInstance$curren3;
|
|
96
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
97
|
+
args[_key] = arguments[_key];
|
|
98
|
+
}
|
|
99
|
+
(_sheetInstance$curren3 = sheetInstance.current) === null || _sheetInstance$curren3 === void 0 || _sheetInstance$curren3.call.apply(_sheetInstance$curren3, [goToByTable].concat(args));
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return (_sheetInstance$curren4 = sheetInstance.current) === null || _sheetInstance$curren4 === void 0 ? void 0 : _sheetInstance$curren4[property];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}, [columns, dataSource, offset]);
|
|
61
106
|
var _useRowSelection = useRowSelection(dataSource, rowSelection, hasChildren),
|
|
62
107
|
_useRowSelection2 = _slicedToArray(_useRowSelection, 2),
|
|
63
108
|
checkedRow = _useRowSelection2[0],
|
|
@@ -74,9 +119,10 @@ var Table = function Table(_ref) {
|
|
|
74
119
|
setData(formatGroupData({
|
|
75
120
|
dataSource: dataSource,
|
|
76
121
|
columns: columns,
|
|
77
|
-
rowKey: rowKey
|
|
122
|
+
rowKey: rowKey,
|
|
123
|
+
showRemark: showRemark
|
|
78
124
|
}));
|
|
79
|
-
}, [dataSource, columns, hasChildren, rowKey]);
|
|
125
|
+
}, [dataSource, columns, hasChildren, rowKey, showRemark]);
|
|
80
126
|
useEffect(function () {
|
|
81
127
|
if (hasChildren) return;
|
|
82
128
|
if (!dataSource || !columns) return;
|
|
@@ -85,15 +131,17 @@ var Table = function Table(_ref) {
|
|
|
85
131
|
columns: columns,
|
|
86
132
|
checked: checkedRow,
|
|
87
133
|
rowKey: rowKey,
|
|
88
|
-
rowSelection: rowSelection
|
|
134
|
+
rowSelection: rowSelection,
|
|
135
|
+
showRemark: showRemark
|
|
89
136
|
}));
|
|
90
|
-
}, [dataSource, columns, checkedRow, hasChildren, rowKey, rowSelection]);
|
|
137
|
+
}, [dataSource, columns, checkedRow, hasChildren, rowKey, rowSelection, showRemark]);
|
|
91
138
|
useEffect(function () {
|
|
92
139
|
if (!dataSource || !columns) {
|
|
93
140
|
setData([[]]);
|
|
94
141
|
}
|
|
95
142
|
}, [dataSource, columns]);
|
|
96
143
|
var handleChanges = useCallback(function (changes, extChange) {
|
|
144
|
+
if (freeze) return;
|
|
97
145
|
onChange && onChange(changes.map(function (item) {
|
|
98
146
|
return {
|
|
99
147
|
col: item.col,
|
|
@@ -111,7 +159,7 @@ var Table = function Table(_ref) {
|
|
|
111
159
|
value: item.value
|
|
112
160
|
};
|
|
113
161
|
}));
|
|
114
|
-
}, [columns, onChange, hasControl]);
|
|
162
|
+
}, [columns, onChange, hasControl, freeze]);
|
|
115
163
|
var handleReverse = useCallback(function (value) {
|
|
116
164
|
var _ref2 = value,
|
|
117
165
|
type = _ref2.type,
|
|
@@ -167,6 +215,102 @@ var Table = function Table(_ref) {
|
|
|
167
215
|
}
|
|
168
216
|
});
|
|
169
217
|
}, [columns.length, columnsTitle, draggable, headSelection, hasChildren]);
|
|
218
|
+
var _useState3 = useState(false),
|
|
219
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
220
|
+
showRemarkPop = _useState4[0],
|
|
221
|
+
setShowRemark = _useState4[1];
|
|
222
|
+
var _useState5 = useState(),
|
|
223
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
224
|
+
remarkInfo = _useState6[0],
|
|
225
|
+
setRemarkInfo = _useState6[1];
|
|
226
|
+
var handleCellClick = useCallback(function (cell) {
|
|
227
|
+
var _columns$dataIndex, _data$row, _data$row2;
|
|
228
|
+
var _ref4 = cell !== null && cell !== void 0 ? cell : {},
|
|
229
|
+
col = _ref4.col,
|
|
230
|
+
row = _ref4.row;
|
|
231
|
+
if (!cell || !(columns !== null && columns !== void 0 && columns.length) || !(data !== null && data !== void 0 && data.length) || !columns[col - offset]) {
|
|
232
|
+
//remove pop
|
|
233
|
+
setShowRemark(false);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
var columnKey = (_columns$dataIndex = columns[col - offset].dataIndex) !== null && _columns$dataIndex !== void 0 ? _columns$dataIndex : '';
|
|
237
|
+
setRemarkInfo({
|
|
238
|
+
cell: cell,
|
|
239
|
+
columnKey: columnKey,
|
|
240
|
+
id: data === null || data === void 0 || (_data$row = data[row]) === null || _data$row === void 0 || (_data$row = _data$row[col]) === null || _data$row === void 0 || (_data$row = _data$row.record) === null || _data$row === void 0 ? void 0 : _data$row.id
|
|
241
|
+
});
|
|
242
|
+
setShowRemark(!!(data !== null && data !== void 0 && (_data$row2 = data[row]) !== null && _data$row2 !== void 0 && (_data$row2 = _data$row2[col]) !== null && _data$row2 !== void 0 && (_data$row2 = _data$row2.record) !== null && _data$row2 !== void 0 && (_data$row2 = _data$row2.remarks) !== null && _data$row2 !== void 0 && _data$row2.includes(columnKey)));
|
|
243
|
+
}, [offset, columns, data]);
|
|
244
|
+
var remarkElement = useMemo(function () {
|
|
245
|
+
if (!showRemark || !remarkInfo || !RemarkRender) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
return /*#__PURE__*/_jsx(RemarkRender, _objectSpread(_objectSpread({}, remarkInfo), {}, {
|
|
249
|
+
close: function close() {
|
|
250
|
+
return setShowRemark(false);
|
|
251
|
+
}
|
|
252
|
+
}));
|
|
253
|
+
}, [RemarkRender, remarkInfo, showRemark, data]);
|
|
254
|
+
var addRemark = useCallback(function (value) {
|
|
255
|
+
handleAddRemark === null || handleAddRemark === void 0 || handleAddRemark(value);
|
|
256
|
+
setShowRemark(true);
|
|
257
|
+
}, [handleAddRemark]);
|
|
258
|
+
var menuRenderer = args.menuRenderer;
|
|
259
|
+
var wrappMenuRenderer = useMemo(function () {
|
|
260
|
+
var remarkMenu = /*#__PURE__*/_jsx("div", {
|
|
261
|
+
className: "harvest-menu-item",
|
|
262
|
+
onClick: function onClick() {
|
|
263
|
+
return addRemark(remarkInfo);
|
|
264
|
+
},
|
|
265
|
+
children: "\u6DFB\u52A0\u8BC4\u8BBA"
|
|
266
|
+
}, "remark");
|
|
267
|
+
if (!menuRenderer) {
|
|
268
|
+
if (showRemark) {
|
|
269
|
+
return function (props) {
|
|
270
|
+
var _data$row3, _target$record, _target$record$includ;
|
|
271
|
+
var cell = props.cell;
|
|
272
|
+
var _ref5 = cell !== null && cell !== void 0 ? cell : {},
|
|
273
|
+
_ref5$col = _ref5.col,
|
|
274
|
+
col = _ref5$col === void 0 ? -1 : _ref5$col,
|
|
275
|
+
_ref5$row = _ref5.row,
|
|
276
|
+
row = _ref5$row === void 0 ? -1 : _ref5$row;
|
|
277
|
+
var target = data === null || data === void 0 || (_data$row3 = data[row]) === null || _data$row3 === void 0 ? void 0 : _data$row3[col + 1];
|
|
278
|
+
var cellHasRemark = (_target$record = target.record) === null || _target$record === void 0 || (_target$record = _target$record.remarks) === null || _target$record === void 0 || (_target$record$includ = _target$record.includes) === null || _target$record$includ === void 0 ? void 0 : _target$record$includ.call(_target$record, target.dataIndex);
|
|
279
|
+
if ((target === null || target === void 0 ? void 0 : target.readonly) !== true && !target.fixed && !cellHasRemark) {
|
|
280
|
+
return /*#__PURE__*/_jsx("div", {
|
|
281
|
+
className: "harvest-menu",
|
|
282
|
+
style: _objectSpread({}, props.position),
|
|
283
|
+
children: remarkMenu
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
return null;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
return undefined;
|
|
290
|
+
} else {
|
|
291
|
+
return function (props) {
|
|
292
|
+
var _data$row4, _target$record2, _target$record2$inclu;
|
|
293
|
+
var cell = props.cell;
|
|
294
|
+
var _ref6 = cell !== null && cell !== void 0 ? cell : {},
|
|
295
|
+
_ref6$col = _ref6.col,
|
|
296
|
+
col = _ref6$col === void 0 ? -1 : _ref6$col,
|
|
297
|
+
_ref6$row = _ref6.row,
|
|
298
|
+
row = _ref6$row === void 0 ? -1 : _ref6$row;
|
|
299
|
+
var target = data === null || data === void 0 || (_data$row4 = data[row]) === null || _data$row4 === void 0 ? void 0 : _data$row4[col + 1];
|
|
300
|
+
var MenuFC = menuRenderer;
|
|
301
|
+
var cellHasRemark = (_target$record2 = target.record) === null || _target$record2 === void 0 || (_target$record2 = _target$record2.remarks) === null || _target$record2 === void 0 || (_target$record2$inclu = _target$record2.includes) === null || _target$record2$inclu === void 0 ? void 0 : _target$record2$inclu.call(_target$record2, target.dataIndex);
|
|
302
|
+
if (showRemark && (target === null || target === void 0 ? void 0 : target.readonly) !== true && !target.fixed && !cellHasRemark) {
|
|
303
|
+
return /*#__PURE__*/_jsx(MenuFC, _objectSpread(_objectSpread({}, props), {}, {
|
|
304
|
+
target: target,
|
|
305
|
+
children: remarkMenu
|
|
306
|
+
}));
|
|
307
|
+
}
|
|
308
|
+
return /*#__PURE__*/_jsx(MenuFC, _objectSpread(_objectSpread({}, props), {}, {
|
|
309
|
+
target: target
|
|
310
|
+
}));
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
}, [showRemark, showRemarkPop, menuRenderer, remarkInfo, addRemark, data]);
|
|
170
314
|
return /*#__PURE__*/_jsx(ConfigProvider, {
|
|
171
315
|
renderEmpty: function renderEmpty() {
|
|
172
316
|
return /*#__PURE__*/_jsx(Empty, {
|
|
@@ -184,11 +328,15 @@ var Table = function Table(_ref) {
|
|
|
184
328
|
onChange: setGroupConfig
|
|
185
329
|
},
|
|
186
330
|
children: /*#__PURE__*/_jsxs(Sheet, _objectSpread(_objectSpread({}, args), {}, {
|
|
331
|
+
freeze: freeze,
|
|
332
|
+
menuRenderer: wrappMenuRenderer,
|
|
333
|
+
showRemark: showRemarkPop,
|
|
187
334
|
sheetInstance: sheetInstance,
|
|
188
335
|
sheetRenderer: WrappedTableShell,
|
|
189
336
|
data: data,
|
|
190
337
|
onCellsChanged: handleChanges,
|
|
191
338
|
handleAdd: handleAdd,
|
|
339
|
+
remarkElement: remarkElement,
|
|
192
340
|
children: [/*#__PURE__*/_jsx(SelectionEvent, {
|
|
193
341
|
hasChildren: hasChildren,
|
|
194
342
|
rowSelection: rowSelection,
|
|
@@ -201,12 +349,14 @@ var Table = function Table(_ref) {
|
|
|
201
349
|
}), /*#__PURE__*/_jsx(SheetEvent, {
|
|
202
350
|
name: "reverse",
|
|
203
351
|
handler: handleReverse
|
|
204
|
-
}, "_reverse"),
|
|
352
|
+
}, "_reverse"), /*#__PURE__*/_jsx(RemarkEvent, {
|
|
353
|
+
handler: handleCellClick
|
|
354
|
+
}), Object.keys(eventHandler || {}).map(function (key) {
|
|
205
355
|
return /*#__PURE__*/_jsx(SheetEvent, {
|
|
206
356
|
name: key,
|
|
207
357
|
handler: eventHandler === null || eventHandler === void 0 ? void 0 : eventHandler[key]
|
|
208
358
|
}, key);
|
|
209
|
-
}), /*#__PURE__*/_jsx(AddButton, {
|
|
359
|
+
}), freeze ? null : /*#__PURE__*/_jsx(AddButton, {
|
|
210
360
|
handleAdd: handleAdd,
|
|
211
361
|
handleBatchAdd: handleBatchAdd
|
|
212
362
|
})]
|
|
@@ -9,4 +9,23 @@
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
+
}
|
|
13
|
+
.remark-cell{
|
|
14
|
+
position: relative !important;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
&::before{
|
|
17
|
+
position: absolute;
|
|
18
|
+
transform: translate(6px,-6px);
|
|
19
|
+
content: '';
|
|
20
|
+
top:4px;
|
|
21
|
+
right:4px;
|
|
22
|
+
border:4px solid transparent;
|
|
23
|
+
border-top-color: red;
|
|
24
|
+
border-right-color: red;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
.harvest-menu-divider{
|
|
28
|
+
margin: 5px 8px;
|
|
29
|
+
height: 1px;
|
|
30
|
+
background-color: rgb(235, 235, 235);
|
|
12
31
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SheetEvent } from "../sheet/Event";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export var RemarkEvent = function RemarkEvent(_ref) {
|
|
4
|
+
var handler = _ref.handler;
|
|
5
|
+
return /*#__PURE__*/_jsx(SheetEvent, {
|
|
6
|
+
name: "cell-select-single",
|
|
7
|
+
handler: handler
|
|
8
|
+
}, "cell-select-single");
|
|
9
|
+
};
|
|
@@ -2,4 +2,4 @@ import type { SheetTableType, SheetType } from "../../type";
|
|
|
2
2
|
export declare const useGroupConfig: (dataSource: Record<string, unknown>[], tableGroupConfig?: SheetTableType.TableGroupConfig, hasChildren?: boolean) => [SheetType.RowGroupConfig & {
|
|
3
3
|
configMap: SheetType.GroupMap;
|
|
4
4
|
}, (value: SheetType.RowGroupConfig) => void];
|
|
5
|
-
export declare const formatGroupData: (param: Pick<SheetTableType.TableProps, 'dataSource' | 'columns' | 'rowKey'>) => SheetType.Cell[][];
|
|
5
|
+
export declare const formatGroupData: (param: Pick<SheetTableType.TableProps, 'dataSource' | 'columns' | 'rowKey' | 'showRemark'>) => SheetType.Cell[][];
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
function _typeof(
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
3
|
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."); }
|
|
4
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
-
function ownKeys(
|
|
7
|
-
function _objectSpread(
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
8
|
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; }
|
|
9
|
-
function _toPropertyKey(
|
|
10
|
-
function _toPrimitive(
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
11
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
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
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
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(
|
|
15
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
17
|
import { flatten, isNil } from 'lodash';
|
|
18
18
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
19
|
-
import { groupConfigToGroupMap } from "../util";
|
|
19
|
+
import { classNames, groupConfigToGroupMap } from "../util";
|
|
20
20
|
import { GroupViewer } from "../viewer";
|
|
21
21
|
import { dataSourceToRowConfig } from "./util";
|
|
22
22
|
export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig, hasChildren) {
|
|
@@ -51,7 +51,7 @@ export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig
|
|
|
51
51
|
rowConfig = rowGroup;
|
|
52
52
|
} else {
|
|
53
53
|
var _tableGroupConfig$onC;
|
|
54
|
-
tableGroupConfig === null || tableGroupConfig === void 0
|
|
54
|
+
tableGroupConfig === null || tableGroupConfig === void 0 || (_tableGroupConfig$onC = tableGroupConfig.onChange) === null || _tableGroupConfig$onC === void 0 || _tableGroupConfig$onC.call(tableGroupConfig, computedRowGroup);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
if (groupConfigRef.current) {
|
|
@@ -87,7 +87,7 @@ export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig
|
|
|
87
87
|
var handleGroupChange = useCallback(function (value) {
|
|
88
88
|
var _tableGroupConfig$onC2;
|
|
89
89
|
setGroupConfig(value);
|
|
90
|
-
tableGroupConfig === null || tableGroupConfig === void 0
|
|
90
|
+
tableGroupConfig === null || tableGroupConfig === void 0 || (_tableGroupConfig$onC2 = tableGroupConfig.onChange) === null || _tableGroupConfig$onC2 === void 0 || _tableGroupConfig$onC2.call(tableGroupConfig, value);
|
|
91
91
|
groupConfigRef.current = value;
|
|
92
92
|
}, [setGroupConfig]);
|
|
93
93
|
var memoConfig = useMemo(function () {
|
|
@@ -104,7 +104,8 @@ export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig
|
|
|
104
104
|
export var formatGroupData = function formatGroupData(param) {
|
|
105
105
|
var dataSource = param.dataSource,
|
|
106
106
|
columns = param.columns,
|
|
107
|
-
rowKey = param.rowKey
|
|
107
|
+
rowKey = param.rowKey,
|
|
108
|
+
showRemark = param.showRemark;
|
|
108
109
|
var data = [];
|
|
109
110
|
var currentIndex = 0;
|
|
110
111
|
dataSource.forEach(function (item, row) {
|
|
@@ -139,16 +140,17 @@ export var formatGroupData = function formatGroupData(param) {
|
|
|
139
140
|
id: rowId,
|
|
140
141
|
row: currentIndex,
|
|
141
142
|
col: -1,
|
|
142
|
-
editable: !((columns === null || columns === void 0 ? void 0 : columns[0].editable) instanceof Function) ? columns === null || columns === void 0
|
|
143
|
-
readonly: !((columns === null || columns === void 0 ? void 0 : columns[0].readonly) instanceof Function) ? columns === null || columns === void 0
|
|
143
|
+
editable: !((columns === null || columns === void 0 ? void 0 : columns[0].editable) instanceof Function) ? columns === null || columns === void 0 || (_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.editable : columns === null || columns === void 0 || (_columns$2 = columns[0]) === null || _columns$2 === void 0 ? void 0 : _columns$2.editable('', itemRow, currentIndex),
|
|
144
|
+
readonly: !((columns === null || columns === void 0 ? void 0 : columns[0].readonly) instanceof Function) ? columns === null || columns === void 0 || (_columns$3 = columns[0]) === null || _columns$3 === void 0 ? void 0 : _columns$3.readonly : columns === null || columns === void 0 || (_columns$4 = columns[0]) === null || _columns$4 === void 0 ? void 0 : _columns$4.readonly('', itemRow, currentIndex),
|
|
144
145
|
align: 'center',
|
|
145
146
|
// fixed: 'unset',
|
|
146
147
|
valueViewer: GroupViewer,
|
|
147
148
|
className: 'sheet-control'
|
|
148
149
|
});
|
|
149
150
|
columns.forEach(function (colInfo, col) {
|
|
150
|
-
var _colInfo$readonly, _colInfo$editable, _colInfo$cellConfig, _colInfo$cellConfig2, _colInfo$cellConfig3;
|
|
151
|
+
var _itemRow$remarks, _colInfo$readonly, _colInfo$editable, _colInfo$cellConfig, _colInfo$cellConfig2, _colInfo$cellConfig3;
|
|
151
152
|
var value = itemRow[colInfo.dataIndex || ''];
|
|
153
|
+
var hasRemark = showRemark && (itemRow === null || itemRow === void 0 || (_itemRow$remarks = itemRow.remarks) === null || _itemRow$remarks === void 0 ? void 0 : _itemRow$remarks.includes(colInfo.dataIndex));
|
|
152
154
|
dataRow.push({
|
|
153
155
|
id: rowId,
|
|
154
156
|
value: value,
|
|
@@ -161,7 +163,7 @@ export var formatGroupData = function formatGroupData(param) {
|
|
|
161
163
|
dataEditor: colInfo.editor ? colInfo.editor : undefined,
|
|
162
164
|
searchKey: colInfo.searchKey,
|
|
163
165
|
row: currentIndex,
|
|
164
|
-
className: !(((_colInfo$cellConfig = colInfo.cellConfig) === null || _colInfo$cellConfig === void 0 ? void 0 : _colInfo$cellConfig.className) instanceof Function) ? (_colInfo$cellConfig2 = colInfo.cellConfig) === null || _colInfo$cellConfig2 === void 0 ? void 0 : _colInfo$cellConfig2.className : (_colInfo$cellConfig3 = colInfo.cellConfig) === null || _colInfo$cellConfig3 === void 0 ? void 0 : _colInfo$cellConfig3.className(value, itemRow, currentIndex),
|
|
166
|
+
className: classNames(!(((_colInfo$cellConfig = colInfo.cellConfig) === null || _colInfo$cellConfig === void 0 ? void 0 : _colInfo$cellConfig.className) instanceof Function) ? (_colInfo$cellConfig2 = colInfo.cellConfig) === null || _colInfo$cellConfig2 === void 0 ? void 0 : _colInfo$cellConfig2.className : (_colInfo$cellConfig3 = colInfo.cellConfig) === null || _colInfo$cellConfig3 === void 0 ? void 0 : _colInfo$cellConfig3.className(value, itemRow, currentIndex), hasRemark ? 'remark-cell' : null),
|
|
165
167
|
dataIndex: colInfo.dataIndex,
|
|
166
168
|
key: colInfo.key,
|
|
167
169
|
allowClear: colInfo.allowClear,
|
|
@@ -1,27 +1,5 @@
|
|
|
1
|
-
import { SheetTableType
|
|
1
|
+
import { SheetTableType } from "../..";
|
|
2
2
|
export declare const useRowSelection: (dataSource: Record<string, unknown>[], rowSelection?: SheetTableType.TableRowSelection, hasChildren?: boolean) => [boolean[], (value: boolean[]) => void];
|
|
3
|
-
export declare const formatSelectionData: (param: Pick<SheetTableType.TableProps, "columns" | "dataSource" | "rowKey" | "rowSelection"> & {
|
|
3
|
+
export declare const formatSelectionData: (param: Pick<SheetTableType.TableProps, "columns" | "dataSource" | "rowKey" | "showRemark" | "rowSelection"> & {
|
|
4
4
|
checked: boolean[];
|
|
5
|
-
}) =>
|
|
6
|
-
id: string;
|
|
7
|
-
row: number;
|
|
8
|
-
col: number;
|
|
9
|
-
editable: boolean;
|
|
10
|
-
readonly: boolean;
|
|
11
|
-
fixed: string;
|
|
12
|
-
valueViewer: () => null;
|
|
13
|
-
className: string;
|
|
14
|
-
align?: undefined;
|
|
15
|
-
value?: undefined;
|
|
16
|
-
} | {
|
|
17
|
-
id: string;
|
|
18
|
-
row: number;
|
|
19
|
-
col: number;
|
|
20
|
-
readonly: boolean;
|
|
21
|
-
align: SheetType.CellAlign;
|
|
22
|
-
value: string;
|
|
23
|
-
valueViewer: SheetType.CellViewer;
|
|
24
|
-
className: string;
|
|
25
|
-
editable?: undefined;
|
|
26
|
-
fixed?: undefined;
|
|
27
|
-
})[][];
|
|
5
|
+
}) => any[][];
|
|
@@ -2,10 +2,11 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
|
|
|
2
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
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
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(
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import { CheckViewer } from "../..";
|
|
8
8
|
import { useEffect, useRef, useState } from 'react';
|
|
9
|
+
import { classNames } from "../util";
|
|
9
10
|
export var useRowSelection = function useRowSelection(dataSource, rowSelection, hasChildren) {
|
|
10
11
|
var _dataSource$length;
|
|
11
12
|
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)),
|
|
@@ -28,7 +29,8 @@ export var formatSelectionData = function formatSelectionData(param) {
|
|
|
28
29
|
columns = param.columns,
|
|
29
30
|
checked = param.checked,
|
|
30
31
|
rowKey = param.rowKey,
|
|
31
|
-
rowSelection = param.rowSelection
|
|
32
|
+
rowSelection = param.rowSelection,
|
|
33
|
+
showRemark = param.showRemark;
|
|
32
34
|
return dataSource.map(function (item, row) {
|
|
33
35
|
var rowId = item.id || item.key || String(row);
|
|
34
36
|
if (rowKey) {
|
|
@@ -64,8 +66,9 @@ export var formatSelectionData = function formatSelectionData(param) {
|
|
|
64
66
|
});
|
|
65
67
|
}
|
|
66
68
|
columns.forEach(function (colInfo, col) {
|
|
67
|
-
var _colInfo$readonly, _colInfo$editable, _colInfo$cellConfig, _colInfo$cellConfig2, _colInfo$cellConfig3;
|
|
69
|
+
var _item$remarks, _colInfo$readonly, _colInfo$editable, _colInfo$cellConfig, _colInfo$cellConfig2, _colInfo$cellConfig3;
|
|
68
70
|
var value = item[colInfo.dataIndex || ''];
|
|
71
|
+
var hasRemark = showRemark && (item === null || item === void 0 || (_item$remarks = item.remarks) === null || _item$remarks === void 0 ? void 0 : _item$remarks.includes(colInfo.dataIndex));
|
|
69
72
|
rows.push({
|
|
70
73
|
id: rowId,
|
|
71
74
|
value: value,
|
|
@@ -77,7 +80,7 @@ export var formatSelectionData = function formatSelectionData(param) {
|
|
|
77
80
|
valueViewer: colInfo.render ? colInfo.render : undefined,
|
|
78
81
|
dataEditor: colInfo.editor ? colInfo.editor : undefined,
|
|
79
82
|
searchKey: colInfo.searchKey,
|
|
80
|
-
className: !(((_colInfo$cellConfig = colInfo.cellConfig) === null || _colInfo$cellConfig === void 0 ? void 0 : _colInfo$cellConfig.className) instanceof Function) ? (_colInfo$cellConfig2 = colInfo.cellConfig) === null || _colInfo$cellConfig2 === void 0 ? void 0 : _colInfo$cellConfig2.className : (_colInfo$cellConfig3 = colInfo.cellConfig) === null || _colInfo$cellConfig3 === void 0 ? void 0 : _colInfo$cellConfig3.className(value, item, row),
|
|
83
|
+
className: classNames(!(((_colInfo$cellConfig = colInfo.cellConfig) === null || _colInfo$cellConfig === void 0 ? void 0 : _colInfo$cellConfig.className) instanceof Function) ? (_colInfo$cellConfig2 = colInfo.cellConfig) === null || _colInfo$cellConfig2 === void 0 ? void 0 : _colInfo$cellConfig2.className : (_colInfo$cellConfig3 = colInfo.cellConfig) === null || _colInfo$cellConfig3 === void 0 ? void 0 : _colInfo$cellConfig3.className(value, item, row), hasRemark ? 'remark-cell' : null),
|
|
81
84
|
row: row,
|
|
82
85
|
col: col,
|
|
83
86
|
dataIndex: colInfo.dataIndex,
|
package/dist/core/util.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
function _typeof(
|
|
2
|
-
function ownKeys(
|
|
3
|
-
function _objectSpread(
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
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(
|
|
6
|
-
function _toPrimitive(
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
8
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
9
|
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."); }
|
|
@@ -175,8 +175,8 @@ export function formatDataToCell(_ref2) {
|
|
|
175
175
|
value: (_pasteData$i$j = pasteData[i][j]) === null || _pasteData$i$j === void 0 ? void 0 : _pasteData$i$j.trimStart().trimEnd()
|
|
176
176
|
});
|
|
177
177
|
} else {
|
|
178
|
-
var _data,
|
|
179
|
-
if (data !== null && data !== void 0 && (_data = data[row + i]) !== null && _data !== void 0 && (
|
|
178
|
+
var _data, _groupMap$get5, _groupMap$get6, _pasteData$i$j2;
|
|
179
|
+
if (data !== null && data !== void 0 && (_data = data[row + i]) !== null && _data !== void 0 && (_data = _data[col + j]) !== null && _data !== void 0 && _data.readonly) return;
|
|
180
180
|
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)) {
|
|
181
181
|
hasStartAndNotOpen = true;
|
|
182
182
|
}
|
|
@@ -210,7 +210,7 @@ export function formatDataToCell(_ref2) {
|
|
|
210
210
|
var lastRow = cells[0].row;
|
|
211
211
|
var pasteCount = 0;
|
|
212
212
|
cells.forEach(function (_ref4) {
|
|
213
|
-
var _data$row$col, _groupMap$get7, _groupMap$get8, _pasteData$pasteCount
|
|
213
|
+
var _data$row$col, _groupMap$get7, _groupMap$get8, _pasteData$pasteCount;
|
|
214
214
|
var row = _ref4.row,
|
|
215
215
|
col = _ref4.col;
|
|
216
216
|
if ((_data$row$col = data[row][col]) !== null && _data$row$col !== void 0 && _data$row$col.readonly) return;
|
|
@@ -224,7 +224,7 @@ export function formatDataToCell(_ref2) {
|
|
|
224
224
|
changes.push({
|
|
225
225
|
row: row,
|
|
226
226
|
col: col,
|
|
227
|
-
value: pasteData === null || pasteData === void 0
|
|
227
|
+
value: pasteData === null || pasteData === void 0 || (_pasteData$pasteCount = pasteData[pasteCount]) === null || _pasteData$pasteCount === void 0 || (_pasteData$pasteCount = _pasteData$pasteCount[col - baseCol]) === null || _pasteData$pasteCount === void 0 ? void 0 : _pasteData$pasteCount.trimStart().trimEnd()
|
|
228
228
|
});
|
|
229
229
|
});
|
|
230
230
|
return {
|
|
@@ -305,7 +305,7 @@ export var groupConfigToGroupMap = function groupConfigToGroupMap(rowGroupConfig
|
|
|
305
305
|
var groupMap = new Map();
|
|
306
306
|
if (!rowGroupConfig || !((_rowGroupConfig$group = rowGroupConfig.groups) !== null && _rowGroupConfig$group !== void 0 && _rowGroupConfig$group.length)) return groupMap;
|
|
307
307
|
var groups = rowGroupConfig.groups;
|
|
308
|
-
groups === null || groups === void 0
|
|
308
|
+
groups === null || groups === void 0 || groups.forEach(function (group, index) {
|
|
309
309
|
var groupStart = group.groupStart,
|
|
310
310
|
groupEnd = group.groupEnd;
|
|
311
311
|
for (var i = groupStart; i <= groupEnd; i++) {
|
|
@@ -408,8 +408,8 @@ export var rowToCountRow = function rowToCountRow(row, groupConfig, max) {
|
|
|
408
408
|
return maxIndex;
|
|
409
409
|
};
|
|
410
410
|
export var getRowHeight = function getRowHeight(container) {
|
|
411
|
-
var _container$getElement
|
|
412
|
-
var h = ((_container$getElement = container.getElementsByTagName('td')[0]) === null || _container$getElement === void 0
|
|
411
|
+
var _container$getElement;
|
|
412
|
+
var h = ((_container$getElement = container.getElementsByTagName('td')[0]) === null || _container$getElement === void 0 || (_container$getElement = _container$getElement.parentNode) === null || _container$getElement === void 0 ? void 0 : _container$getElement.clientHeight) || 30;
|
|
413
413
|
return h;
|
|
414
414
|
};
|
|
415
415
|
export var getNextVisibleRow = function getNextVisibleRow(row, maxRow, groupMap) {
|
|
@@ -459,7 +459,7 @@ export var calcMenuPosition = function calcMenuPosition(_ref5) {
|
|
|
459
459
|
};
|
|
460
460
|
export var isFreezedCell = function isFreezedCell(row, col, data) {
|
|
461
461
|
var _data$row$col$classNa;
|
|
462
|
-
var isFreezed = (data === null || data === void 0 ? void 0 : data[row][col].fixed) || (data === null || data === void 0
|
|
462
|
+
var isFreezed = (data === null || data === void 0 ? void 0 : data[row][col].fixed) || (data === null || data === void 0 || (_data$row$col$classNa = data[row][col].className) === null || _data$row$col$classNa === void 0 ? void 0 : _data$row$col$classNa.includes('sheet-control'));
|
|
463
463
|
return !!isFreezed;
|
|
464
464
|
};
|
|
465
465
|
export var stripRowIndex = function stripRowIndex(data) {
|
|
@@ -489,7 +489,7 @@ export var ensureFocus = function ensureFocus(container) {
|
|
|
489
489
|
focusInterval = undefined;
|
|
490
490
|
}
|
|
491
491
|
focusInterval = setInterval(function () {
|
|
492
|
-
container === null || container === void 0
|
|
492
|
+
container === null || container === void 0 || container.focus();
|
|
493
493
|
}, 100);
|
|
494
494
|
setTimeout(function () {
|
|
495
495
|
clearInterval(focusInterval);
|