@zhenliang/sheet 0.1.30 → 0.1.32
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/numberEditor/index.js +7 -2
- package/dist/core/sheet/index.js +39 -23
- package/dist/core/sheet/index.less +25 -5
- package/dist/core/table/useGroupConfig.js +2 -0
- package/dist/core/table/useRowSelection.js +3 -1
- package/dist/core/viewer/switchViewer/index.js +8 -2
- package/dist/type/sheet.d.ts +1 -0
- package/dist/type/sheetTable.d.ts +1 -0
- package/package.json +1 -1
|
@@ -50,7 +50,7 @@ export var getNumberEditor = function getNumberEditor(extraProps, getExtraProps)
|
|
|
50
50
|
var _ref = getExtraProps ? getExtraProps(props) : extraProps !== null && extraProps !== void 0 ? extraProps : {},
|
|
51
51
|
precision = _ref.precision,
|
|
52
52
|
inputArgs = _objectWithoutProperties(_ref, _excluded);
|
|
53
|
-
var
|
|
53
|
+
var baseFormatter = useCallback(function (value) {
|
|
54
54
|
if (!value) {
|
|
55
55
|
return '';
|
|
56
56
|
}
|
|
@@ -63,10 +63,15 @@ export var getNumberEditor = function getNumberEditor(extraProps, getExtraProps)
|
|
|
63
63
|
}
|
|
64
64
|
return String(value);
|
|
65
65
|
}, []);
|
|
66
|
+
// 去掉多余的0
|
|
67
|
+
var valueFormatter = useCallback(function (value) {
|
|
68
|
+
var baseValue = baseFormatter(value);
|
|
69
|
+
return baseValue ? "".concat(parseFloat(baseValue)) : '';
|
|
70
|
+
}, []);
|
|
66
71
|
/**
|
|
67
72
|
* 重新声明,后面有需求可以改一下
|
|
68
73
|
*/
|
|
69
|
-
var valueParser =
|
|
74
|
+
var valueParser = baseFormatter;
|
|
70
75
|
var handleChange = useCallback(function (value) {
|
|
71
76
|
onChange && onChange(value ? value : null);
|
|
72
77
|
}, [onChange]);
|
package/dist/core/sheet/index.js
CHANGED
|
@@ -6,6 +6,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import { useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
8
8
|
// import ReduxLogger from 'redux-logger';
|
|
9
|
+
import cls from 'classnames';
|
|
9
10
|
import ReduxThunk from 'redux-thunk';
|
|
10
11
|
import DefaultRow from "./DefaultRow";
|
|
11
12
|
import DefaultShell from "./DefaultShell";
|
|
@@ -54,7 +55,10 @@ var Sheet = function Sheet(props) {
|
|
|
54
55
|
scroll = props.scroll,
|
|
55
56
|
children = props.children,
|
|
56
57
|
showBackEdit = props.showBackEdit,
|
|
57
|
-
backEditStyle = props.backEditStyle
|
|
58
|
+
backEditStyle = props.backEditStyle,
|
|
59
|
+
_props$boldScroll = props.boldScroll,
|
|
60
|
+
boldScroll = _props$boldScroll === void 0 ? true : _props$boldScroll;
|
|
61
|
+
var scrollWarpRef = useRef(null);
|
|
58
62
|
var sheetWrapperRef = useRef(null);
|
|
59
63
|
var contextMenuRef = useRef(null);
|
|
60
64
|
var eventBus = useEventBus();
|
|
@@ -227,34 +231,46 @@ var Sheet = function Sheet(props) {
|
|
|
227
231
|
}
|
|
228
232
|
return null;
|
|
229
233
|
}, [isEmptyData, emptyRenderer]);
|
|
234
|
+
var hasHorizontalScrollbar = scrollWarpRef.current && scrollWarpRef.current.scrollWidth > scrollWarpRef.current.clientWidth;
|
|
230
235
|
return /*#__PURE__*/_jsx(SheetEventContext.Provider, {
|
|
231
236
|
value: eventBus,
|
|
232
237
|
children: /*#__PURE__*/_jsxs("span", {
|
|
233
|
-
children: [/*#__PURE__*/
|
|
234
|
-
ref:
|
|
235
|
-
tabIndex: 0,
|
|
236
|
-
className: classNames('harvest harvest-sheet-container', className),
|
|
238
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
239
|
+
ref: scrollWarpRef,
|
|
237
240
|
style: {
|
|
238
|
-
|
|
239
|
-
width: (_scroll$x = scroll === null || scroll === void 0 ? void 0 : scroll.x) !== null && _scroll$x !== void 0 ? _scroll$x : '100%'
|
|
241
|
+
overflow: 'auto'
|
|
240
242
|
},
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
243
|
+
className: cls({
|
|
244
|
+
tableWarpScroll: hasHorizontalScrollbar && boldScroll
|
|
245
|
+
}),
|
|
246
|
+
children: /*#__PURE__*/_jsxs("span", {
|
|
247
|
+
ref: sheetWrapperRef,
|
|
248
|
+
tabIndex: 0,
|
|
249
|
+
className: classNames('harvest harvest-sheet-container', className),
|
|
250
|
+
style: {
|
|
251
|
+
maxHeight: (_scroll$y = scroll === null || scroll === void 0 ? void 0 : scroll.y) !== null && _scroll$y !== void 0 ? _scroll$y : memoHeight,
|
|
252
|
+
width: (_scroll$x = scroll === null || scroll === void 0 ? void 0 : scroll.x) !== null && _scroll$x !== void 0 ? _scroll$x : 'calc(100% - 1px)'
|
|
253
|
+
},
|
|
254
|
+
children: [/*#__PURE__*/_jsxs(SheetShell, {
|
|
255
|
+
className: classNames('harvest-sheet', className),
|
|
256
|
+
children: [/*#__PURE__*/_jsx(VirtualizeStart, {
|
|
257
|
+
virtualized: virtualized,
|
|
258
|
+
paddingTop: paddingTop
|
|
259
|
+
}), rowElements, /*#__PURE__*/_jsx(VirtualizeEnd, {
|
|
260
|
+
virtualized: virtualized,
|
|
261
|
+
paddingBottom: paddingBottom
|
|
262
|
+
})]
|
|
263
|
+
}, "sheet"), /*#__PURE__*/_jsx(Menu, {
|
|
264
|
+
ref: contextMenuRef,
|
|
265
|
+
position: menu.position,
|
|
266
|
+
cell: menu.cellPosition,
|
|
267
|
+
showMenu: menu.showMenu,
|
|
268
|
+
contextMenu: ContextMenu,
|
|
269
|
+
onContextMenu: onContextMenu
|
|
270
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
271
|
+
className: 'sheet-pd10'
|
|
249
272
|
})]
|
|
250
|
-
}
|
|
251
|
-
ref: contextMenuRef,
|
|
252
|
-
position: menu.position,
|
|
253
|
-
cell: menu.cellPosition,
|
|
254
|
-
showMenu: menu.showMenu,
|
|
255
|
-
contextMenu: ContextMenu,
|
|
256
|
-
onContextMenu: onContextMenu
|
|
257
|
-
})]
|
|
273
|
+
})
|
|
258
274
|
}), EmptyElement, /*#__PURE__*/_jsxs("div", {
|
|
259
275
|
className: "harvest-sheet-control",
|
|
260
276
|
children: [children, /*#__PURE__*/_jsx(Control, {
|
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
@import './var.less';
|
|
2
2
|
|
|
3
|
+
.sheet-pd10 {
|
|
4
|
+
height: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.tableWarpScroll {
|
|
8
|
+
&::-webkit-scrollbar {
|
|
9
|
+
display: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&:hover {
|
|
13
|
+
margin-bottom: 10px;
|
|
14
|
+
|
|
15
|
+
.sheet-pd10 {
|
|
16
|
+
height: 10px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&::-webkit-scrollbar {
|
|
20
|
+
display: block;
|
|
21
|
+
height: 10px;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
3
27
|
.harvest-sheet-container{
|
|
4
|
-
overflow: auto;
|
|
5
28
|
display: block;
|
|
6
29
|
position: relative ;
|
|
7
30
|
// scroll-behavior:smooth;
|
|
@@ -46,10 +69,7 @@ span.harvest-sheet-container, span.harvest-sheet-container:focus {
|
|
|
46
69
|
.harvest-sheet-container .harvest-sheet .cell {
|
|
47
70
|
height: 17px;
|
|
48
71
|
font-size: var(--cell-font-size);
|
|
49
|
-
padding
|
|
50
|
-
padding-right:var(--cell-padding-horizontal);
|
|
51
|
-
padding-top:var(--cell-padding-vertical);
|
|
52
|
-
padding-bottom:var(--cell-padding-vertical);
|
|
72
|
+
padding:var(--cell-padding-vertical) var(--cell-padding-horizontal) var(--cell-padding-vertical) var(--cell-padding-horizontal);
|
|
53
73
|
border: 1px solid var(--cell-border-color);
|
|
54
74
|
background-color: var(--cell-background-color);
|
|
55
75
|
cursor: cell;
|
|
@@ -131,6 +131,8 @@ export var formatGroupData = function formatGroupData(param) {
|
|
|
131
131
|
dataEditor: colInfo.editor ? colInfo.editor : undefined,
|
|
132
132
|
row: currentIndex,
|
|
133
133
|
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),
|
|
134
|
+
dataIndex: colInfo.dataIndex,
|
|
135
|
+
key: colInfo.key,
|
|
134
136
|
col: col
|
|
135
137
|
});
|
|
136
138
|
});
|
|
@@ -66,7 +66,9 @@ export var formatSelectionData = function formatSelectionData(param) {
|
|
|
66
66
|
dataEditor: colInfo.editor ? colInfo.editor : undefined,
|
|
67
67
|
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),
|
|
68
68
|
row: row,
|
|
69
|
-
col: col
|
|
69
|
+
col: col,
|
|
70
|
+
dataIndex: colInfo.dataIndex,
|
|
71
|
+
key: colInfo.key
|
|
70
72
|
});
|
|
71
73
|
});
|
|
72
74
|
return rows;
|
|
@@ -5,17 +5,23 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
5
5
|
export var SwitchViewer = function SwitchViewer(props) {
|
|
6
6
|
var value = props.value,
|
|
7
7
|
row = props.row,
|
|
8
|
-
record = props.record
|
|
8
|
+
record = props.record,
|
|
9
|
+
cell = props.cell;
|
|
10
|
+
var _ref = cell !== null && cell !== void 0 ? cell : {},
|
|
11
|
+
key = _ref.key,
|
|
12
|
+
readonly = _ref.readonly;
|
|
9
13
|
var eventBus = useSheetEvent();
|
|
10
14
|
var handleChange = useCallback(function () {
|
|
11
15
|
if (!eventBus) return;
|
|
12
16
|
eventBus.emit('cell-switch', {
|
|
13
17
|
row: row,
|
|
14
18
|
record: record,
|
|
15
|
-
value: !value
|
|
19
|
+
value: !value,
|
|
20
|
+
key: key
|
|
16
21
|
});
|
|
17
22
|
}, [eventBus, row, record, value]);
|
|
18
23
|
return /*#__PURE__*/_jsx(Switch, {
|
|
24
|
+
disabled: readonly,
|
|
19
25
|
checked: value,
|
|
20
26
|
onChange: handleChange
|
|
21
27
|
});
|
package/dist/type/sheet.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ export type SheetProps = {
|
|
|
114
114
|
};
|
|
115
115
|
rowClassName?: string | ((record: Record<string, unknown>, index: number) => string);
|
|
116
116
|
children?: any[];
|
|
117
|
+
boldScroll?: boolean;
|
|
117
118
|
};
|
|
118
119
|
export type WidthConfigContext = {
|
|
119
120
|
onChange?: (value: Record<number | string, number>) => void;
|
|
@@ -87,4 +87,5 @@ export type TableProps = {
|
|
|
87
87
|
onChange: (changes: TableChange[], extChanges?: TableChange[]) => void;
|
|
88
88
|
handleAdd?: () => void;
|
|
89
89
|
eventHandler?: Record<'reverse' | 'btn-click' | 'cell-edit' | 'cell-switch' | string, undefined | EventHandler>;
|
|
90
|
+
boldScroll?: boolean;
|
|
90
91
|
};
|