@zhenliang/sheet 0.1.28 → 0.1.29

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.
@@ -17,7 +17,8 @@ export var keyboardReducer = {
17
17
  data = _state$data === void 0 ? [] : _state$data;
18
18
  var newRow = (((_state$start = state.start) === null || _state$start === void 0 ? void 0 : _state$start.row) || 0) + row;
19
19
  if (groupConfig) {
20
- newRow = getNextVisibleRow(newRow, data.length, groupConfigToGroupMap(groupConfig), row < 0 ? -1 : 1);
20
+ var _data;
21
+ newRow = getNextVisibleRow(newRow, (data === null || data === void 0 || (_data = data[data.length - 1]) === null || _data === void 0 ? void 0 : _data[0].row) || data.length, groupConfigToGroupMap(groupConfig), row < 0 ? -1 : 1);
21
22
  }
22
23
  var currentPos = {
23
24
  row: newRow,
@@ -86,7 +86,7 @@ var Sheet = function Sheet(props) {
86
86
  data = _getState.data;
87
87
  var container = sheetWrapperRef.current;
88
88
  if (!start && isNil(row)) return;
89
- var actual = rowToActualRow((_ref = row) !== null && _ref !== void 0 ? _ref : start === null || start === void 0 ? void 0 : start.row, groupConfig);
89
+ var actual = rowToActualRow((_ref = row) !== null && _ref !== void 0 ? _ref : start === null || start === void 0 ? void 0 : start.row, groupConfig, data.length);
90
90
  var rowHeight = getRowHeight(container);
91
91
  var firstRowCell = container.querySelector("td.cell[data-col='".concat(start === null || start === void 0 ? void 0 : start.col, "']"));
92
92
  var colPosition = firstRowCell ? firstRowCell.offsetLeft - firstRowCell.clientWidth : 0;
@@ -20,6 +20,7 @@ export var useSelectVisible = function useSelectVisible(sheetWrapper, start) {
20
20
  var handleScroll = throttle(function () {
21
21
  var _sheetWrapper$current, _sheetWrapper$current2;
22
22
  if (!start) {
23
+ setStartVisible(true);
23
24
  return;
24
25
  }
25
26
  var startCell = (_sheetWrapper$current = sheetWrapper.current) === null || _sheetWrapper$current === void 0 ? void 0 : _sheetWrapper$current.querySelector("td.cell[data-row='".concat(start.row, "']"));
@@ -147,14 +147,18 @@ export var DraggableShell = function DraggableShell(_ref) {
147
147
  var _downRef$current$oldW, _downRef$current$oldX;
148
148
  downRef.current.style.cursor = 'default';
149
149
  if (((_downRef$current$oldW = downRef.current.oldWidth) !== null && _downRef$current$oldW !== void 0 ? _downRef$current$oldW : 0) + (e.x - ((_downRef$current$oldX = downRef.current.oldX) !== null && _downRef$current$oldX !== void 0 ? _downRef$current$oldX : 0)) > 0) {
150
- var _downRef$current$oldW2, _downRef$current$oldX2, _headRef$current;
150
+ var _downRef$current$oldW2, _downRef$current$oldX2, _headRef$current, _columns$actualIndex$;
151
151
  var newWidth = Math.max(Number(((_downRef$current$oldW2 = downRef.current.oldWidth) !== null && _downRef$current$oldW2 !== void 0 ? _downRef$current$oldW2 : 0) + (e.x - ((_downRef$current$oldX2 = downRef.current.oldX) !== null && _downRef$current$oldX2 !== void 0 ? _downRef$current$oldX2 : 0))), 50);
152
152
  var cellList = [].slice.call((_headRef$current = headRef.current) === null || _headRef$current === void 0 ? void 0 : _headRef$current.cells);
153
153
  var changeIndex = cellList.indexOf(downRef.current);
154
+ var actualIndex = hasControl ? changeIndex - 1 : changeIndex;
155
+ var isDoubleSpan = (((_columns$actualIndex$ = columns[actualIndex].titleConfig) === null || _columns$actualIndex$ === void 0 ? void 0 : _columns$actualIndex$.colSpan) || 0) > 1;
156
+ var nextColumn = columns[actualIndex + 1] || {};
157
+ var nextWidth = +String(nextColumn === null || nextColumn === void 0 ? void 0 : nextColumn.width).replace('px', '');
154
158
  //调整该列中的每个Cell
155
159
  var _widths2 = _defineProperty({
156
160
  length: columns.length
157
- }, hasControl ? changeIndex - 1 : changeIndex, newWidth);
161
+ }, actualIndex, isDoubleSpan ? newWidth - nextWidth : newWidth);
158
162
  setWidth(_widths2);
159
163
  }
160
164
  }
@@ -177,6 +181,9 @@ export var DraggableShell = function DraggableShell(_ref) {
177
181
  children: [/*#__PURE__*/_jsx("colgroup", {
178
182
  children: colItems
179
183
  }), /*#__PURE__*/_jsx("thead", {
184
+ style: {
185
+ pointerEvents: 'all'
186
+ },
180
187
  children: /*#__PURE__*/_jsx("tr", {
181
188
  ref: headRef,
182
189
  children: thItems
package/dist/core/util.js CHANGED
@@ -97,7 +97,7 @@ export function stringToClipboardData(str, count) {
97
97
  });
98
98
  }
99
99
  export var defaultParsePaste = function defaultParsePaste(str) {
100
- return str.split(/\r\n|\n|\r/).map(function (row) {
100
+ return str.trim().split(/\r\n|\n|\r/).map(function (row) {
101
101
  return row.split('\t');
102
102
  });
103
103
  };
@@ -189,7 +189,7 @@ export function formatDataToCell(_ref2) {
189
189
  });
190
190
  });
191
191
  if (hasStartAndNotOpen) {
192
- console.error('有折叠单元格,不可粘贴');
192
+ message.error('有折叠单元格,不可粘贴');
193
193
  return {
194
194
  changes: [],
195
195
  extChanges: []
@@ -355,7 +355,7 @@ export var changeGroupConfig = function changeGroupConfig(rowGroupConfig, change
355
355
  });
356
356
  };
357
357
  export var rowToActualRow = function rowToActualRow(row, groupConfig) {
358
- var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10000;
358
+ var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 100000;
359
359
  var groupMap = groupConfigToGroupMap(groupConfig);
360
360
  if (!groupMap.size || row < 0) return row;
361
361
  var openCount = 0;
@@ -33,7 +33,8 @@ export var GroupViewer = function GroupViewer(props) {
33
33
  var currentOpen = record !== null && record !== void 0 && record.isHeader ? allOpen : isOpen;
34
34
  return /*#__PURE__*/_jsx("span", {
35
35
  style: {
36
- cursor: 'pointer'
36
+ cursor: 'pointer',
37
+ pointerEvents: 'all'
37
38
  },
38
39
  onMouseDown: function onMouseDown(e) {
39
40
  return e.stopPropagation();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",