@zhenliang/sheet 0.1.1 → 0.1.3
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.
|
@@ -3,4 +3,4 @@ import { InputNumberProps } from 'antd';
|
|
|
3
3
|
import 'antd/es/input-number/style/index.css';
|
|
4
4
|
import './index.less';
|
|
5
5
|
export declare const NumberEditor: SheetType.CellEditor;
|
|
6
|
-
export declare const getNumberEditor: (extraProps?: Pick<InputNumberProps, 'max' | 'min' | 'addonBefore' | 'addonAfter' | 'precision'
|
|
6
|
+
export declare const getNumberEditor: (extraProps?: Partial<Pick<InputNumberProps, 'max' | 'min' | 'addonBefore' | 'addonAfter' | 'precision'>>) => SheetType.CellEditor;
|
|
@@ -106,14 +106,18 @@ export var stateReducer = {
|
|
|
106
106
|
});
|
|
107
107
|
},
|
|
108
108
|
selectRow: function selectRow(state, payload) {
|
|
109
|
-
var _state$data4, _state$data4$, _state$data5, _state$data5$, _state$data6, _state$data6$;
|
|
109
|
+
var _state$data4, _state$data4$, _state$data$0$length, _state$data5, _state$data5$, _state$data6, _state$data6$;
|
|
110
110
|
var startCol = ((_state$data4 = state.data) === null || _state$data4 === void 0 ? void 0 : (_state$data4$ = _state$data4[0]) === null || _state$data4$ === void 0 ? void 0 : _state$data4$.findIndex(function (item) {
|
|
111
111
|
return !item.fixed;
|
|
112
112
|
})) || 0;
|
|
113
|
-
var endCol = (((_state$data5 = state.data) === null || _state$data5 === void 0 ? void 0 : (_state$data5$ = _state$data5[0]) === null || _state$data5$ === void 0 ? void 0 : _state$data5$.
|
|
113
|
+
var endCol = ((_state$data$0$length = (_state$data5 = state.data) === null || _state$data5 === void 0 ? void 0 : (_state$data5$ = _state$data5[0]) === null || _state$data5$ === void 0 ? void 0 : _state$data5$.length) !== null && _state$data$0$length !== void 0 ? _state$data$0$length : 0) - 1;
|
|
114
|
+
var lastFixed = (_state$data6 = state.data) === null || _state$data6 === void 0 ? void 0 : (_state$data6$ = _state$data6[0]) === null || _state$data6$ === void 0 ? void 0 : _state$data6$.find(function (item) {
|
|
114
115
|
return item.fixed === SheetType.CellAlign.right;
|
|
115
|
-
})
|
|
116
|
-
|
|
116
|
+
});
|
|
117
|
+
if (lastFixed) {
|
|
118
|
+
var _state$data$0$indexOf, _state$data7;
|
|
119
|
+
endCol = (_state$data$0$indexOf = (_state$data7 = state.data) === null || _state$data7 === void 0 ? void 0 : _state$data7[0].indexOf(lastFixed)) !== null && _state$data$0$indexOf !== void 0 ? _state$data$0$indexOf : 0 - 1;
|
|
120
|
+
}
|
|
117
121
|
if (startCol >= 0 && endCol >= 0) {
|
|
118
122
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
119
123
|
start: {
|
|
@@ -130,7 +134,7 @@ export var stateReducer = {
|
|
|
130
134
|
}
|
|
131
135
|
});
|
|
132
136
|
}
|
|
133
|
-
return
|
|
137
|
+
return state;
|
|
134
138
|
},
|
|
135
139
|
clearSelect: function clearSelect(state) {
|
|
136
140
|
var start = state.start,
|
package/dist/core/sheet/index.js
CHANGED
|
@@ -202,7 +202,7 @@ var Sheet = function Sheet(props) {
|
|
|
202
202
|
paddingBottom: paddingTop,
|
|
203
203
|
display: 'block'
|
|
204
204
|
}
|
|
205
|
-
}), rowElements, /*#__PURE__*/_jsx("tr", {
|
|
205
|
+
}), rowElements, virtualized && paddingBottom > 0 && /*#__PURE__*/_jsx("tr", {
|
|
206
206
|
style: {
|
|
207
207
|
height: 0,
|
|
208
208
|
paddingBottom: paddingBottom,
|
|
@@ -27,13 +27,21 @@ span.harvest-sheet-container, span.harvest-sheet-container:focus {
|
|
|
27
27
|
tr{
|
|
28
28
|
height:var(--row-height);
|
|
29
29
|
|
|
30
|
-
th{
|
|
30
|
+
th.cell-title{
|
|
31
31
|
line-height: var(--row-height);
|
|
32
|
+
border-bottom: 1px solid transparent;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
td{
|
|
35
36
|
line-height: var(--row-height);
|
|
36
37
|
}
|
|
38
|
+
|
|
39
|
+
&:last-of-type{
|
|
40
|
+
.td{
|
|
41
|
+
border-bottom: 1px solid transparent;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
}
|
|
@@ -239,6 +247,7 @@ span.harvest-sheet-container, span.harvest-sheet-container:focus {
|
|
|
239
247
|
display: block;
|
|
240
248
|
font-size: var(--cell-font-size);
|
|
241
249
|
line-height:var(--cell-inner-height) ;
|
|
250
|
+
height:var(--cell-inner-height) ;
|
|
242
251
|
padding:0
|
|
243
252
|
}
|
|
244
253
|
|
|
@@ -4,6 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
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
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
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { flatten } from 'lodash';
|
|
7
8
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
8
9
|
import { dataSourceToRowConfig } from "./util";
|
|
9
10
|
export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig, hasChildren) {
|
|
@@ -15,13 +16,12 @@ export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig
|
|
|
15
16
|
var childrenLength = useMemo(function () {
|
|
16
17
|
if (!(dataSource !== null && dataSource !== void 0 && dataSource.length)) return 0;
|
|
17
18
|
var data = dataSource;
|
|
18
|
-
var childrenCount = data.filter(function (item) {
|
|
19
|
+
var childrenCount = flatten(data.filter(function (item) {
|
|
19
20
|
var _item$children;
|
|
20
21
|
return !!((_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length);
|
|
21
|
-
}).
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}, 0);
|
|
22
|
+
}).map(function (item) {
|
|
23
|
+
return item.children;
|
|
24
|
+
})).length;
|
|
25
25
|
return childrenCount;
|
|
26
26
|
}, [dataSource]);
|
|
27
27
|
useEffect(function () {
|
|
@@ -29,9 +29,9 @@ export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig
|
|
|
29
29
|
console.log('groupConfigEffect', dataSource.length);
|
|
30
30
|
var rowConfig = dataSourceToRowConfig(dataSource, tableGroupConfig === null || tableGroupConfig === void 0 ? void 0 : tableGroupConfig.defaultOpen);
|
|
31
31
|
if (groupConfigRef.current) {
|
|
32
|
-
groupConfigRef.current.groups.forEach(function (
|
|
32
|
+
groupConfigRef.current.groups.forEach(function (_ref, index) {
|
|
33
33
|
var _groupConfigRef$curre;
|
|
34
|
-
var groupName =
|
|
34
|
+
var groupName = _ref.groupName;
|
|
35
35
|
var rowIndex = rowConfig.groups.findIndex(function (item) {
|
|
36
36
|
return item.groupName === groupName;
|
|
37
37
|
});
|
|
@@ -42,6 +42,7 @@ export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig
|
|
|
42
42
|
console.log('groupConfigEffect', rowConfig.groups, rowConfig.groupOpen);
|
|
43
43
|
groupConfigRef.current = rowConfig;
|
|
44
44
|
}, [dataSource.length, childrenLength, hasChildren]);
|
|
45
|
+
console.log('groupConfigEffect', dataSource.length, childrenLength);
|
|
45
46
|
var handleGroupChange = useCallback(function (value) {
|
|
46
47
|
setGroupConfig(value);
|
|
47
48
|
groupConfigRef.current = value;
|
|
@@ -80,6 +80,8 @@ export declare type TableProps = {
|
|
|
80
80
|
backEditStyle?: Partial<CSSStyleDeclaration>;
|
|
81
81
|
rowSelection?: TableRowSelection;
|
|
82
82
|
groupConfig?: TableGroupConfig;
|
|
83
|
+
menuRenderer?: React.FC<SheetType.MenuRenderProps>;
|
|
84
|
+
onContextMenu?: (event: any) => void;
|
|
83
85
|
onChange: (changes: TableChange[], extChanges?: TableChange[]) => void;
|
|
84
86
|
handleAdd?: () => void;
|
|
85
87
|
eventHandler?: Record<'reverse' | 'btn-click' | 'cell-edit' | 'cell-switch' | string, undefined | EventHandler>;
|