@zhenliang/sheet 0.1.28 → 0.1.30
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/selectEditor/index.js +1 -1
- package/dist/core/editor/selectEditor/index.less +4 -0
- package/dist/core/reducers/keyboardReducer.js +2 -1
- package/dist/core/sheet/index.js +1 -1
- package/dist/core/sheet/useSelectVisible.js +1 -0
- package/dist/core/shell/draggableShell/index.js +9 -2
- package/dist/core/table/index.js +46 -39
- package/dist/core/util.js +3 -3
- package/dist/core/viewer/groupViewer/index.js +2 -1
- package/package.json +1 -1
|
@@ -63,7 +63,7 @@ export var getSelectEditor = function getSelectEditor(options) {
|
|
|
63
63
|
onChange: handleChange,
|
|
64
64
|
onKeyDown: handleKeyDown,
|
|
65
65
|
options: customOptions,
|
|
66
|
-
popupClassName:
|
|
66
|
+
popupClassName: "select-editor-dropdown",
|
|
67
67
|
dropdownRender: dropdown
|
|
68
68
|
}));
|
|
69
69
|
};
|
|
@@ -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
|
-
|
|
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,
|
package/dist/core/sheet/index.js
CHANGED
|
@@ -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
|
-
},
|
|
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/table/index.js
CHANGED
|
@@ -16,7 +16,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
16
16
|
import { Sheet, useSetState } from "../..";
|
|
17
17
|
import { GroupContext } from "../../hooks/useGroupConfig";
|
|
18
18
|
import { WidthContext } from "../../hooks/useWidthConfig";
|
|
19
|
-
import { Button } from 'antd';
|
|
19
|
+
import { Button, ConfigProvider, Empty } from 'antd';
|
|
20
20
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
21
21
|
import { SheetEvent } from "../sheet/Event";
|
|
22
22
|
import { DraggableShell } from "../shell/draggableShell";
|
|
@@ -157,48 +157,55 @@ var Table = function Table(_ref) {
|
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
159
|
}, [columns.length, draggable, headSelection, hasChildren]);
|
|
160
|
-
return /*#__PURE__*/_jsx(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
return /*#__PURE__*/_jsx(ConfigProvider, {
|
|
161
|
+
renderEmpty: function renderEmpty() {
|
|
162
|
+
return /*#__PURE__*/_jsx(Empty, {
|
|
163
|
+
image: Empty.PRESENTED_IMAGE_SIMPLE
|
|
164
|
+
});
|
|
164
165
|
},
|
|
165
|
-
children: /*#__PURE__*/_jsx(
|
|
166
|
+
children: /*#__PURE__*/_jsx(WidthContext.Provider, {
|
|
166
167
|
value: {
|
|
167
|
-
|
|
168
|
-
onChange:
|
|
168
|
+
widths: widths,
|
|
169
|
+
onChange: setWidth
|
|
169
170
|
},
|
|
170
|
-
children: /*#__PURE__*/
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
children:
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
onChange: handleRowSelect
|
|
179
|
-
}), /*#__PURE__*/_jsx(GroupEvent, {
|
|
180
|
-
hasChildren: hasChildren,
|
|
171
|
+
children: /*#__PURE__*/_jsx(GroupContext.Provider, {
|
|
172
|
+
value: {
|
|
173
|
+
config: rowGroupConfig,
|
|
174
|
+
onChange: setGroupConfig
|
|
175
|
+
},
|
|
176
|
+
children: /*#__PURE__*/_jsxs(Sheet, _objectSpread(_objectSpread({}, args), {}, {
|
|
177
|
+
sheetInstance: sheetInstance,
|
|
178
|
+
sheetRenderer: WrappedTableShell,
|
|
181
179
|
data: data,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
180
|
+
onCellsChanged: handleChanges,
|
|
181
|
+
children: [/*#__PURE__*/_jsx(SelectionEvent, {
|
|
182
|
+
hasChildren: hasChildren,
|
|
183
|
+
rowSelection: rowSelection,
|
|
184
|
+
onChange: handleRowSelect
|
|
185
|
+
}), /*#__PURE__*/_jsx(GroupEvent, {
|
|
186
|
+
hasChildren: hasChildren,
|
|
187
|
+
data: data,
|
|
188
|
+
sheetInstance: sheetInstance.current,
|
|
189
|
+
onGridChange: setData
|
|
190
|
+
}), /*#__PURE__*/_jsx(SheetEvent, {
|
|
191
|
+
name: "reverse",
|
|
192
|
+
handler: handleReverse
|
|
193
|
+
}, "_reverse"), Object.keys(eventHandler || {}).map(function (key) {
|
|
194
|
+
return /*#__PURE__*/_jsx(SheetEvent, {
|
|
195
|
+
name: key,
|
|
196
|
+
handler: eventHandler === null || eventHandler === void 0 ? void 0 : eventHandler[key]
|
|
197
|
+
}, key);
|
|
198
|
+
}), handleAdd ? /*#__PURE__*/_jsx(Button, {
|
|
199
|
+
type: "dashed",
|
|
200
|
+
style: {
|
|
201
|
+
width: '100%',
|
|
202
|
+
height: 32
|
|
203
|
+
},
|
|
204
|
+
onClick: handleAdd,
|
|
205
|
+
children: "+ \u6DFB\u52A0"
|
|
206
|
+
}) : null]
|
|
207
|
+
}))
|
|
208
|
+
})
|
|
202
209
|
})
|
|
203
210
|
});
|
|
204
211
|
};
|
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
|
-
|
|
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] :
|
|
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();
|