@zhenliang/sheet 0.1.7-3.beta.1 → 0.1.7-3.beta.2
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/sheet/Remark.d.ts +9 -0
- package/dist/core/sheet/Remark.js +29 -0
- package/dist/core/sheet/index.js +23 -1
- package/dist/core/sheet/index.less +13 -0
- package/dist/core/sheet/useContextMenu.js +3 -3
- package/dist/core/sheet/useRemarkContainer.d.ts +14 -0
- package/dist/core/sheet/useRemarkContainer.js +120 -0
- package/dist/core/shell/draggableShell/index.d.ts +1 -1
- package/dist/core/shell/draggableShell/index.js +5 -0
- package/dist/core/shell/tableShell.d.ts +2 -2
- package/dist/core/shell/tableShell.js +11 -155
- package/dist/core/table/addButton.d.ts +0 -1
- package/dist/core/table/addButton.js +0 -1
- package/dist/core/table/index.d.ts +1 -0
- package/dist/core/table/index.js +82 -6
- package/dist/core/table/index.less +19 -0
- package/dist/core/table/remarkEvent.d.ts +5 -0
- package/dist/core/table/remarkEvent.js +13 -0
- package/dist/core/table/useGroupConfig.d.ts +1 -1
- package/dist/core/table/useGroupConfig.js +6 -4
- package/dist/core/table/useRowSelection.d.ts +1 -1
- package/dist/core/table/useRowSelection.js +6 -3
- package/dist/example/valuationAnalyze.js +285 -10
- package/dist/type/sheet.d.ts +5 -1
- package/dist/type/sheetTable.d.ts +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { forwardRef, useMemo } from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export var Remark = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
4
|
+
var showRemark = props.showRemark,
|
|
5
|
+
children = props.children,
|
|
6
|
+
position = props.position;
|
|
7
|
+
var transform = useMemo(function () {
|
|
8
|
+
if (document.body.clientWidth - position.left < 200) {
|
|
9
|
+
return 'translate(-100%,40px)';
|
|
10
|
+
}
|
|
11
|
+
return '';
|
|
12
|
+
}, [position.left]);
|
|
13
|
+
return /*#__PURE__*/_jsx("div", {
|
|
14
|
+
ref: ref,
|
|
15
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
16
|
+
className: "harvest-remark-container",
|
|
17
|
+
style: {
|
|
18
|
+
position: 'fixed',
|
|
19
|
+
top: position.top,
|
|
20
|
+
left: position.left,
|
|
21
|
+
transform: transform,
|
|
22
|
+
opacity: showRemark ? 1 : 0,
|
|
23
|
+
pointerEvents: showRemark ? 'all' : 'none',
|
|
24
|
+
minWidth: showRemark ? 200 : 0
|
|
25
|
+
},
|
|
26
|
+
children: showRemark ? children : null
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
});
|
package/dist/core/sheet/index.js
CHANGED
|
@@ -18,12 +18,14 @@ import { classNames, getRowHeight, rowToActualRow } from "../util";
|
|
|
18
18
|
import { Control } from "./Control";
|
|
19
19
|
import { DefaultRowMapper } from "./DefaultRowMapper";
|
|
20
20
|
import { Menu } from "./Menu";
|
|
21
|
+
import { Remark } from "./Remark";
|
|
21
22
|
import "./index.less";
|
|
22
23
|
import { SearchInput } from "./searchInput";
|
|
23
24
|
import { useCellEvent } from "./useCellEvent";
|
|
24
25
|
import { useContextMenu } from "./useContextMenu";
|
|
25
26
|
import { useKeyBoardEvent } from "./useKeyBoardEvent";
|
|
26
27
|
import { useMouseEvent } from "./useMouseEvent";
|
|
28
|
+
import { useRemarkContainer } from "./useRemarkContainer";
|
|
27
29
|
import { useSearchInput } from "./useSearchInput";
|
|
28
30
|
import { useSelectVisible } from "./useSelectVisible";
|
|
29
31
|
import { VirtualizeEnd, VirtualizeStart, useVirtualList } from "./useVirtualList";
|
|
@@ -56,6 +58,7 @@ var Sheet = function Sheet(props) {
|
|
|
56
58
|
rowClassName = props.rowClassName,
|
|
57
59
|
scroll = props.scroll,
|
|
58
60
|
children = props.children,
|
|
61
|
+
ControlContainer = props.ControlContainer,
|
|
59
62
|
_props$showBackEdit = props.showBackEdit,
|
|
60
63
|
showBackEdit = _props$showBackEdit === void 0 ? true : _props$showBackEdit,
|
|
61
64
|
backEditStyle = props.backEditStyle,
|
|
@@ -65,7 +68,9 @@ var Sheet = function Sheet(props) {
|
|
|
65
68
|
hideColBar = _props$hideColBar === void 0 ? true : _props$hideColBar,
|
|
66
69
|
_props$showQuickLocat = props.showQuickLocationBtn,
|
|
67
70
|
showQuickLocationBtn = _props$showQuickLocat === void 0 ? false : _props$showQuickLocat,
|
|
68
|
-
|
|
71
|
+
_props$showRemark = props.showRemark,
|
|
72
|
+
showRemark = _props$showRemark === void 0 ? false : _props$showRemark,
|
|
73
|
+
remarkElement = props.remarkElement;
|
|
69
74
|
var _useState = useState(false),
|
|
70
75
|
_useState2 = _slicedToArray(_useState, 2),
|
|
71
76
|
isScrolledOver = _useState2[0],
|
|
@@ -199,6 +204,8 @@ var Sheet = function Sheet(props) {
|
|
|
199
204
|
useMouseEvent(dispatch, sheetWrapperRef);
|
|
200
205
|
useKeyBoardEvent(dispatch, sheetWrapperRef);
|
|
201
206
|
var menu = useContextMenu(dispatch, sheetWrapperRef, !!ContextMenu, contextMenuRef);
|
|
207
|
+
var _useRemarkContainer = useRemarkContainer(sheetWrapperRef, state.start, state.editing, showRemark),
|
|
208
|
+
remarkInfo = _useRemarkContainer.remarkInfo;
|
|
202
209
|
|
|
203
210
|
// timeout 的副作用不适合放reducer里面
|
|
204
211
|
useEffect(function () {
|
|
@@ -235,6 +242,13 @@ var Sheet = function Sheet(props) {
|
|
|
235
242
|
changeSearch = _useSearchInput.changeSearch,
|
|
236
243
|
goNext = _useSearchInput.goNext,
|
|
237
244
|
goLast = _useSearchInput.goLast;
|
|
245
|
+
useEffect(function () {
|
|
246
|
+
if (!state.mouseDown && state.start && state.end && state.start.row === state.end.row && state.start.col === state.end.col) {
|
|
247
|
+
eventBus.emit('cell-select-single', state.start);
|
|
248
|
+
} else {
|
|
249
|
+
eventBus.emit('cell-select-single', null);
|
|
250
|
+
}
|
|
251
|
+
}, [state.start, state.end, state.mouseDown]);
|
|
238
252
|
useEffect(function () {
|
|
239
253
|
dispatch({
|
|
240
254
|
type: 'clearEdit'
|
|
@@ -322,6 +336,7 @@ var Sheet = function Sheet(props) {
|
|
|
322
336
|
handleScroll();
|
|
323
337
|
}
|
|
324
338
|
}, []);
|
|
339
|
+
console.log(menu.showMenu);
|
|
325
340
|
return /*#__PURE__*/_jsx(SheetEventContext.Provider, {
|
|
326
341
|
value: eventBus,
|
|
327
342
|
children: /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -356,6 +371,13 @@ var Sheet = function Sheet(props) {
|
|
|
356
371
|
showMenu: menu.showMenu,
|
|
357
372
|
contextMenu: ContextMenu,
|
|
358
373
|
onContextMenu: onContextMenu
|
|
374
|
+
}), /*#__PURE__*/_jsx(Remark, {
|
|
375
|
+
showRemark: remarkInfo.show && !menu.showMenu,
|
|
376
|
+
position: {
|
|
377
|
+
left: remarkInfo.position.left,
|
|
378
|
+
top: remarkInfo.position.top
|
|
379
|
+
},
|
|
380
|
+
children: remarkElement
|
|
359
381
|
}), EmptyElement]
|
|
360
382
|
}), /*#__PURE__*/_jsxs("div", {
|
|
361
383
|
className: "harvest-sheet-control",
|
|
@@ -378,3 +378,16 @@ span.harvest-sheet-container:focus {
|
|
|
378
378
|
color: #a4a9b2;
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
+
.harvest-sheet-container .harvest-remark-container{
|
|
382
|
+
opacity: 1;
|
|
383
|
+
border:1px solid #E5E5E5;
|
|
384
|
+
border-radius: 2px;
|
|
385
|
+
z-index: 10;
|
|
386
|
+
margin-left: 5px;
|
|
387
|
+
transition: min-height .2s linear,height .2s linear;
|
|
388
|
+
padding: 8px;
|
|
389
|
+
overflow: hidden;
|
|
390
|
+
background: rgb(255,255,255);
|
|
391
|
+
// box-shadow: 2px 2px 5px #888888;
|
|
392
|
+
box-shadow: 0 4px 8px rgba(216,223,235,.5);
|
|
393
|
+
}
|
|
@@ -37,10 +37,10 @@ export var useContextMenu = function useContextMenu(dispatch, elementRef) {
|
|
|
37
37
|
if (!currentCell) return;
|
|
38
38
|
var currentPos = extractDataRowAndCol(currentCell);
|
|
39
39
|
dispatch({
|
|
40
|
-
type: '
|
|
40
|
+
type: 'select',
|
|
41
41
|
payload: {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
start: currentPos,
|
|
43
|
+
end: currentPos
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
var _calcMenuPosition = calcMenuPosition({
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SheetType } from "../../type";
|
|
2
|
+
export declare const useRemarkContainer: (elementRef: React.RefObject<SheetType.refAssertion>, start?: SheetType.CellPosition, editing?: SheetType.CellPosition, showRemark?: boolean) => {
|
|
3
|
+
remarkInfo: {
|
|
4
|
+
position: {
|
|
5
|
+
top: number;
|
|
6
|
+
left: number;
|
|
7
|
+
};
|
|
8
|
+
cellPosition: {
|
|
9
|
+
row: number;
|
|
10
|
+
col: number;
|
|
11
|
+
};
|
|
12
|
+
show: boolean;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
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(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
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import { useSetState } from "../../hooks";
|
|
14
|
+
import { useCallback, useEffect } from 'react';
|
|
15
|
+
import { debounce } from 'lodash';
|
|
16
|
+
export var useRemarkContainer = function useRemarkContainer(elementRef, start, editing) {
|
|
17
|
+
var showRemark = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
18
|
+
var _useSetState = useSetState({
|
|
19
|
+
position: {
|
|
20
|
+
top: 0,
|
|
21
|
+
left: 0
|
|
22
|
+
},
|
|
23
|
+
cellPosition: {
|
|
24
|
+
row: 0,
|
|
25
|
+
col: 0
|
|
26
|
+
},
|
|
27
|
+
show: showRemark
|
|
28
|
+
}),
|
|
29
|
+
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
30
|
+
remarkInfo = _useSetState2[0],
|
|
31
|
+
setRemarkInfo = _useSetState2[1];
|
|
32
|
+
var calcPosition = useCallback(function () {
|
|
33
|
+
if (!start || !showRemark || !elementRef.current) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
var cell = elementRef.current.querySelector("td[data-row=\"".concat(start.row, "\"][data-col=\"").concat(start.col, "\"]"));
|
|
37
|
+
if (!cell) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
var containerRect = elementRef.current.getBoundingClientRect();
|
|
41
|
+
var cellRect = cell.getBoundingClientRect();
|
|
42
|
+
var visible = containerRect.top < cellRect.top && containerRect.left < cellRect.left && containerRect.top + (containerRect === null || containerRect === void 0 ? void 0 : containerRect.height) > cellRect.bottom && containerRect.left + (containerRect === null || containerRect === void 0 ? void 0 : containerRect.width) > (cellRect === null || cellRect === void 0 ? void 0 : cellRect.right);
|
|
43
|
+
return {
|
|
44
|
+
top: cellRect.y,
|
|
45
|
+
left: cellRect.x + cellRect.width,
|
|
46
|
+
visible: visible
|
|
47
|
+
};
|
|
48
|
+
}, [start, showRemark]);
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
var position = calcPosition();
|
|
51
|
+
if (!position) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
setRemarkInfo({
|
|
55
|
+
position: position
|
|
56
|
+
});
|
|
57
|
+
}, [start, showRemark]);
|
|
58
|
+
useEffect(function () {
|
|
59
|
+
setRemarkInfo({
|
|
60
|
+
show: showRemark && !editing
|
|
61
|
+
});
|
|
62
|
+
}, [showRemark, editing]);
|
|
63
|
+
useEffect(function () {
|
|
64
|
+
var _elementRef$current, _elementRef$current2;
|
|
65
|
+
var remarkScroll = debounce(function () {
|
|
66
|
+
setRemarkInfo({
|
|
67
|
+
show: false
|
|
68
|
+
});
|
|
69
|
+
}, 50);
|
|
70
|
+
var remarkScrollEnd = function remarkScrollEnd() {
|
|
71
|
+
var position = calcPosition();
|
|
72
|
+
if (!position) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
setRemarkInfo({
|
|
76
|
+
position: position,
|
|
77
|
+
show: position.visible && showRemark && !editing && position.left > 0 && position.top > 0
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
(_elementRef$current = elementRef.current) === null || _elementRef$current === void 0 || _elementRef$current.addEventListener('scroll', remarkScroll);
|
|
81
|
+
(_elementRef$current2 = elementRef.current) === null || _elementRef$current2 === void 0 || _elementRef$current2.addEventListener('scrollend', remarkScrollEnd);
|
|
82
|
+
return function () {
|
|
83
|
+
var _elementRef$current3, _elementRef$current4;
|
|
84
|
+
(_elementRef$current3 = elementRef.current) === null || _elementRef$current3 === void 0 || _elementRef$current3.removeEventListener('scroll', remarkScroll);
|
|
85
|
+
(_elementRef$current4 = elementRef.current) === null || _elementRef$current4 === void 0 || _elementRef$current4.removeEventListener('scrollend', remarkScrollEnd);
|
|
86
|
+
};
|
|
87
|
+
}, [start, showRemark, editing]);
|
|
88
|
+
useEffect(function () {
|
|
89
|
+
var _elementRef$current5;
|
|
90
|
+
if (!start) return;
|
|
91
|
+
var cell = (_elementRef$current5 = elementRef.current) === null || _elementRef$current5 === void 0 ? void 0 : _elementRef$current5.querySelector("td[data-row=\"".concat(start.row, "\"][data-col=\"").concat(start.col, "\"]"));
|
|
92
|
+
if (!cell) return;
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
94
|
+
if (!cell) {
|
|
95
|
+
return function () {};
|
|
96
|
+
}
|
|
97
|
+
var io = new IntersectionObserver(function (entries) {
|
|
98
|
+
var ratio = entries[0].intersectionRatio;
|
|
99
|
+
console.log('io-ratio', ratio);
|
|
100
|
+
if (ratio < 1) setRemarkInfo({
|
|
101
|
+
show: false
|
|
102
|
+
});
|
|
103
|
+
}, {
|
|
104
|
+
threshold: 1
|
|
105
|
+
});
|
|
106
|
+
io.observe(cell);
|
|
107
|
+
return function () {
|
|
108
|
+
var _io2;
|
|
109
|
+
if (cell) {
|
|
110
|
+
var _io;
|
|
111
|
+
(_io = io) === null || _io === void 0 || _io.unobserve(cell);
|
|
112
|
+
}
|
|
113
|
+
(_io2 = io) === null || _io2 === void 0 || _io2.disconnect();
|
|
114
|
+
io = undefined;
|
|
115
|
+
};
|
|
116
|
+
}, [start]);
|
|
117
|
+
return {
|
|
118
|
+
remarkInfo: _objectSpread({}, remarkInfo)
|
|
119
|
+
};
|
|
120
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { SheetType } from "../../../type";
|
|
3
3
|
import './index.less';
|
|
4
|
-
export declare const DraggableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
|
|
4
|
+
export declare const DraggableShell: ({ columns, className, showGroup, showSelect, controlProps, dragable, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
|
|
5
5
|
children: React.ReactElement;
|
|
6
6
|
isScrolledOver: boolean;
|
|
7
7
|
isScrolledToEnd: boolean;
|
|
@@ -23,6 +23,8 @@ export var DraggableShell = function DraggableShell(_ref) {
|
|
|
23
23
|
showGroup = _ref.showGroup,
|
|
24
24
|
showSelect = _ref.showSelect,
|
|
25
25
|
controlProps = _ref.controlProps,
|
|
26
|
+
_ref$dragable = _ref.dragable,
|
|
27
|
+
dragable = _ref$dragable === void 0 ? true : _ref$dragable,
|
|
26
28
|
_ref$controlWidth = _ref.controlWidth,
|
|
27
29
|
controlWidth = _ref$controlWidth === void 0 ? 30 : _ref$controlWidth;
|
|
28
30
|
var TableShell = function TableShell(_ref2) {
|
|
@@ -203,6 +205,9 @@ export var DraggableShell = function DraggableShell(_ref) {
|
|
|
203
205
|
return ths;
|
|
204
206
|
}, [columns, colItems, isScrolledOver, isScrolledToEnd]);
|
|
205
207
|
useEffect(function () {
|
|
208
|
+
if (!dragable) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
206
211
|
var handleMouseUp = function handleMouseUp() {
|
|
207
212
|
//结束宽度调整
|
|
208
213
|
if (downRef.current) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { SheetType } from "../../type";
|
|
3
3
|
import './draggableShell/index.less';
|
|
4
|
-
export declare const TableShell: (
|
|
5
|
-
children:
|
|
4
|
+
export declare const TableShell: (props: SheetType.SheetShell) => import("react").FC<{
|
|
5
|
+
children: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
6
6
|
isScrolledOver: boolean;
|
|
7
7
|
isScrolledToEnd: boolean;
|
|
8
8
|
}>;
|
|
@@ -1,157 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
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(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); }
|
|
6
7
|
import "./draggableShell/index.less";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
className = _ref.className,
|
|
13
|
-
showGroup = _ref.showGroup,
|
|
14
|
-
showSelect = _ref.showSelect,
|
|
15
|
-
controlProps = _ref.controlProps,
|
|
16
|
-
_ref$controlWidth = _ref.controlWidth,
|
|
17
|
-
controlWidth = _ref$controlWidth === void 0 ? 30 : _ref$controlWidth;
|
|
18
|
-
var TableShell = function TableShell(_ref2) {
|
|
19
|
-
var children = _ref2.children,
|
|
20
|
-
isScrolledOver = _ref2.isScrolledOver,
|
|
21
|
-
isScrolledToEnd = _ref2.isScrolledToEnd;
|
|
22
|
-
var eventBus = useSheetEvent();
|
|
23
|
-
var colItems = useMemo(function () {
|
|
24
|
-
var cols = [];
|
|
25
|
-
if (showGroup || showSelect) {
|
|
26
|
-
cols.push( /*#__PURE__*/_jsx("col", {
|
|
27
|
-
className: classNames('sheet-control'),
|
|
28
|
-
style: {
|
|
29
|
-
width: controlWidth,
|
|
30
|
-
border: 'none'
|
|
31
|
-
}
|
|
32
|
-
}, "sheet-control"));
|
|
33
|
-
}
|
|
34
|
-
columns.forEach(function (item, index) {
|
|
35
|
-
cols.push( /*#__PURE__*/_jsx("col", {
|
|
36
|
-
className: classNames('cell'),
|
|
37
|
-
style: {
|
|
38
|
-
width: item.width || 'unset',
|
|
39
|
-
border: 'none'
|
|
40
|
-
}
|
|
41
|
-
}, item.dataIndex || index));
|
|
42
|
-
});
|
|
43
|
-
return cols;
|
|
44
|
-
}, [columns, showGroup || showSelect, controlWidth]);
|
|
45
|
-
var thItems = useMemo(function () {
|
|
46
|
-
var ths = [];
|
|
47
|
-
var hasControl = showGroup || showSelect;
|
|
48
|
-
var positionArr = [];
|
|
49
|
-
if (hasControl) {
|
|
50
|
-
var _controlProps$group, _controlProps$check, _controlProps$check2, _controlProps$check3;
|
|
51
|
-
ths.push( /*#__PURE__*/_jsxs("th", {
|
|
52
|
-
className: "cell cell-title read-only sheet-control",
|
|
53
|
-
children: [showGroup && /*#__PURE__*/_jsx(GroupViewer, {
|
|
54
|
-
row: -1,
|
|
55
|
-
col: -1,
|
|
56
|
-
value: true,
|
|
57
|
-
record: {
|
|
58
|
-
open: controlProps === null || controlProps === void 0 || (_controlProps$group = controlProps.group) === null || _controlProps$group === void 0 ? void 0 : _controlProps$group.open,
|
|
59
|
-
isHeader: true
|
|
60
|
-
}
|
|
61
|
-
}), showSelect && /*#__PURE__*/_jsx(CheckViewer, {
|
|
62
|
-
row: -1,
|
|
63
|
-
col: -1,
|
|
64
|
-
value: controlProps === null || controlProps === void 0 || (_controlProps$check = controlProps.check) === null || _controlProps$check === void 0 ? void 0 : _controlProps$check.checked,
|
|
65
|
-
record: {
|
|
66
|
-
open: controlProps === null || controlProps === void 0 || (_controlProps$check2 = controlProps.check) === null || _controlProps$check2 === void 0 ? void 0 : _controlProps$check2.checked,
|
|
67
|
-
isHeader: true,
|
|
68
|
-
indeterminate: controlProps === null || controlProps === void 0 || (_controlProps$check3 = controlProps.check) === null || _controlProps$check3 === void 0 ? void 0 : _controlProps$check3.indeterminate
|
|
69
|
-
}
|
|
70
|
-
})]
|
|
71
|
-
}, "-1"));
|
|
72
|
-
positionArr.push({
|
|
73
|
-
isLastFixedLeft: false,
|
|
74
|
-
isFirstFixedRight: false,
|
|
75
|
-
fixPosition: 0
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
var fixLeftPosition = 0;
|
|
79
|
-
var fixRightPosition = columns.reduce(function (pre, cur, index) {
|
|
80
|
-
if (cur.fixed === 'right') {
|
|
81
|
-
var positionIndex = hasControl ? index + 1 : index;
|
|
82
|
-
return pre + colItems[positionIndex].props.style.width;
|
|
83
|
-
}
|
|
84
|
-
return pre + 0;
|
|
85
|
-
}, 0);
|
|
86
|
-
columns.forEach(function (item, index) {
|
|
87
|
-
var _item$titleConfig, _item$titleConfig2, _ref3;
|
|
88
|
-
var positionIndex = hasControl ? index + 1 : index;
|
|
89
|
-
if (item.fixed === 'right') {
|
|
90
|
-
fixRightPosition -= colItems[positionIndex].props.style.width;
|
|
91
|
-
}
|
|
92
|
-
var isLastFixedLeft = item.fixed === 'left' && !columns.slice(index + 1).some(function (item) {
|
|
93
|
-
return item.fixed === 'left';
|
|
94
|
-
});
|
|
95
|
-
var isFirstFixedRight = item.fixed === 'right' && !columns.slice(0, index).some(function (item) {
|
|
96
|
-
return item.fixed === 'right';
|
|
97
|
-
});
|
|
98
|
-
positionArr.push({
|
|
99
|
-
isLastFixedLeft: isLastFixedLeft,
|
|
100
|
-
isFirstFixedRight: isFirstFixedRight,
|
|
101
|
-
fixPosition: item.fixed === 'right' ? fixRightPosition : fixLeftPosition
|
|
102
|
-
});
|
|
103
|
-
((_item$titleConfig = item.titleConfig) === null || _item$titleConfig === void 0 ? void 0 : _item$titleConfig.colSpan) !== 0 && ths.push( /*#__PURE__*/_jsx("th", {
|
|
104
|
-
className: classNames('cell', 'cell-title', 'read-only', item.fixed && 'fixed', item.fixed && "fixed-".concat(item.fixed), isLastFixedLeft && isScrolledOver ? "last-fixed-left" : '', isFirstFixedRight && !isScrolledToEnd ? "first-fixed-right" : ''),
|
|
105
|
-
colSpan: (_item$titleConfig2 = item.titleConfig) === null || _item$titleConfig2 === void 0 ? void 0 : _item$titleConfig2.colSpan,
|
|
106
|
-
onClick: function onClick() {
|
|
107
|
-
eventBus.emit('col-select', {
|
|
108
|
-
col: index
|
|
109
|
-
});
|
|
110
|
-
},
|
|
111
|
-
style: {
|
|
112
|
-
textAlign: (_ref3 = item.align) !== null && _ref3 !== void 0 ? _ref3 : 'unset',
|
|
113
|
-
cursor: 'e-resizer',
|
|
114
|
-
left: item.fixed === 'left' ? fixLeftPosition : 'unset',
|
|
115
|
-
right: item.fixed === 'right' ? fixRightPosition : 'unset'
|
|
116
|
-
},
|
|
117
|
-
children: /*#__PURE__*/_jsx("span", {
|
|
118
|
-
className: "value-viewer",
|
|
119
|
-
children: item.title
|
|
120
|
-
})
|
|
121
|
-
}, item.dataIndex || index));
|
|
122
|
-
if (item.fixed === 'left') {
|
|
123
|
-
fixLeftPosition += colItems[positionIndex].props.style.width;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
setTimeout(function () {
|
|
127
|
-
eventBus.emit('change-fixed-position', positionArr);
|
|
128
|
-
}, 16);
|
|
129
|
-
return ths;
|
|
130
|
-
}, [columns, showGroup || showSelect, controlProps, isScrolledOver, isScrolledToEnd]);
|
|
131
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
132
|
-
children: [/*#__PURE__*/_jsxs("table", {
|
|
133
|
-
className: classNames('header', 'harvest-sheet', className),
|
|
134
|
-
style: {
|
|
135
|
-
position: 'sticky',
|
|
136
|
-
top: 0,
|
|
137
|
-
zIndex: 3
|
|
138
|
-
},
|
|
139
|
-
children: [/*#__PURE__*/_jsx("colgroup", {
|
|
140
|
-
children: colItems
|
|
141
|
-
}), /*#__PURE__*/_jsx("thead", {
|
|
142
|
-
children: /*#__PURE__*/_jsx("tr", {
|
|
143
|
-
children: thItems
|
|
144
|
-
})
|
|
145
|
-
})]
|
|
146
|
-
}, "header"), /*#__PURE__*/_jsxs("table", {
|
|
147
|
-
className: classNames('body', 'harvest-sheet'),
|
|
148
|
-
children: [/*#__PURE__*/_jsx("colgroup", {
|
|
149
|
-
children: colItems
|
|
150
|
-
}), /*#__PURE__*/_jsx("tbody", {
|
|
151
|
-
children: children
|
|
152
|
-
}, "tbody")]
|
|
153
|
-
}, "body")]
|
|
154
|
-
});
|
|
155
|
-
};
|
|
156
|
-
return TableShell;
|
|
8
|
+
import { DraggableShell } from "./draggableShell";
|
|
9
|
+
export var TableShell = function TableShell(props) {
|
|
10
|
+
return DraggableShell(_objectSpread(_objectSpread({}, props), {}, {
|
|
11
|
+
dragable: false
|
|
12
|
+
}));
|
|
157
13
|
};
|
|
@@ -7,7 +7,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
7
7
|
import { MoreOutlined } from "@ant-design/icons";
|
|
8
8
|
import { Form, InputNumber, Popover, Button } from "antd";
|
|
9
9
|
import React, { useEffect, useRef, useState } from "react";
|
|
10
|
-
import "./index.less";
|
|
11
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
12
|
var RowPop = function RowPop(props) {
|
package/dist/core/table/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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"];
|
|
2
|
+
var _excluded = ["sheetInstance", "columns", "dataSource", "rowKey", "rowSelection", "groupConfig", "onChange", "handleAdd", "handleBatchAdd", "draggable", "eventHandler", "remarkRender", "handleAddRemark", "showRemark"];
|
|
3
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
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; }
|
|
@@ -23,6 +23,8 @@ 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,10 @@ 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,
|
|
42
48
|
args = _objectWithoutProperties(_ref, _excluded);
|
|
43
49
|
var _useState = useState([[]]),
|
|
44
50
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -74,9 +80,10 @@ var Table = function Table(_ref) {
|
|
|
74
80
|
setData(formatGroupData({
|
|
75
81
|
dataSource: dataSource,
|
|
76
82
|
columns: columns,
|
|
77
|
-
rowKey: rowKey
|
|
83
|
+
rowKey: rowKey,
|
|
84
|
+
showRemark: showRemark
|
|
78
85
|
}));
|
|
79
|
-
}, [dataSource, columns, hasChildren, rowKey]);
|
|
86
|
+
}, [dataSource, columns, hasChildren, rowKey, showRemark]);
|
|
80
87
|
useEffect(function () {
|
|
81
88
|
if (hasChildren) return;
|
|
82
89
|
if (!dataSource || !columns) return;
|
|
@@ -85,9 +92,10 @@ var Table = function Table(_ref) {
|
|
|
85
92
|
columns: columns,
|
|
86
93
|
checked: checkedRow,
|
|
87
94
|
rowKey: rowKey,
|
|
88
|
-
rowSelection: rowSelection
|
|
95
|
+
rowSelection: rowSelection,
|
|
96
|
+
showRemark: showRemark
|
|
89
97
|
}));
|
|
90
|
-
}, [dataSource, columns, checkedRow, hasChildren, rowKey, rowSelection]);
|
|
98
|
+
}, [dataSource, columns, checkedRow, hasChildren, rowKey, rowSelection, showRemark]);
|
|
91
99
|
useEffect(function () {
|
|
92
100
|
if (!dataSource || !columns) {
|
|
93
101
|
setData([[]]);
|
|
@@ -167,6 +175,69 @@ var Table = function Table(_ref) {
|
|
|
167
175
|
}
|
|
168
176
|
});
|
|
169
177
|
}, [columns.length, columnsTitle, draggable, headSelection, hasChildren]);
|
|
178
|
+
var _useState3 = useState(false),
|
|
179
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
180
|
+
showRemarkPop = _useState4[0],
|
|
181
|
+
setShowRemark = _useState4[1];
|
|
182
|
+
var _useState5 = useState(),
|
|
183
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
184
|
+
remarkInfo = _useState6[0],
|
|
185
|
+
setRemarkInfo = _useState6[1];
|
|
186
|
+
var handleCellClick = useCallback(function (cell) {
|
|
187
|
+
var _columns$dataIndex, _data$row, _data$row2;
|
|
188
|
+
var _ref4 = cell !== null && cell !== void 0 ? cell : {},
|
|
189
|
+
col = _ref4.col,
|
|
190
|
+
row = _ref4.row;
|
|
191
|
+
if (!cell || !(columns !== null && columns !== void 0 && columns.length) || !(data !== null && data !== void 0 && data.length) || !columns[col - offset]) {
|
|
192
|
+
//remove pop
|
|
193
|
+
setShowRemark(false);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
var columnKey = (_columns$dataIndex = columns[col - offset].dataIndex) !== null && _columns$dataIndex !== void 0 ? _columns$dataIndex : '';
|
|
197
|
+
setRemarkInfo({
|
|
198
|
+
cell: cell,
|
|
199
|
+
columnKey: columnKey,
|
|
200
|
+
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
|
|
201
|
+
});
|
|
202
|
+
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)));
|
|
203
|
+
}, [offset, columns, data]);
|
|
204
|
+
var remarkElement = useMemo(function () {
|
|
205
|
+
if (!showRemark || !remarkInfo) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
return remarkRender === null || remarkRender === void 0 ? void 0 : remarkRender(remarkInfo);
|
|
209
|
+
}, [remarkRender, remarkInfo, showRemark]);
|
|
210
|
+
var menuRenderer = args.menuRenderer;
|
|
211
|
+
var wrappMenuRenderer = useMemo(function () {
|
|
212
|
+
var remarkMenu = /*#__PURE__*/_jsx("div", {
|
|
213
|
+
className: "harvest-menu-item",
|
|
214
|
+
onClick: function onClick() {
|
|
215
|
+
return remarkInfo && (handleAddRemark === null || handleAddRemark === void 0 ? void 0 : handleAddRemark(remarkInfo));
|
|
216
|
+
},
|
|
217
|
+
children: "\u6DFB\u52A0\u8BC4\u8BBA"
|
|
218
|
+
});
|
|
219
|
+
if (!menuRenderer) {
|
|
220
|
+
if (showRemark) {
|
|
221
|
+
return function (props) {
|
|
222
|
+
return /*#__PURE__*/_jsx("div", {
|
|
223
|
+
className: "harvest-menu",
|
|
224
|
+
style: _objectSpread({}, props.position),
|
|
225
|
+
children: remarkMenu
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return undefined;
|
|
230
|
+
} else {
|
|
231
|
+
return function (props) {
|
|
232
|
+
var MenuFC = menuRenderer;
|
|
233
|
+
return /*#__PURE__*/_jsxs(MenuFC, _objectSpread(_objectSpread({}, props), {}, {
|
|
234
|
+
children: [remarkMenu, /*#__PURE__*/_jsx("div", {
|
|
235
|
+
className: "harvest-menu-divider"
|
|
236
|
+
})]
|
|
237
|
+
}));
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}, [showRemark, showRemarkPop, menuRenderer, remarkInfo]);
|
|
170
241
|
return /*#__PURE__*/_jsx(ConfigProvider, {
|
|
171
242
|
renderEmpty: function renderEmpty() {
|
|
172
243
|
return /*#__PURE__*/_jsx(Empty, {
|
|
@@ -184,11 +255,14 @@ var Table = function Table(_ref) {
|
|
|
184
255
|
onChange: setGroupConfig
|
|
185
256
|
},
|
|
186
257
|
children: /*#__PURE__*/_jsxs(Sheet, _objectSpread(_objectSpread({}, args), {}, {
|
|
258
|
+
menuRenderer: wrappMenuRenderer,
|
|
259
|
+
showRemark: showRemarkPop,
|
|
187
260
|
sheetInstance: sheetInstance,
|
|
188
261
|
sheetRenderer: WrappedTableShell,
|
|
189
262
|
data: data,
|
|
190
263
|
onCellsChanged: handleChanges,
|
|
191
264
|
handleAdd: handleAdd,
|
|
265
|
+
remarkElement: remarkElement,
|
|
192
266
|
children: [/*#__PURE__*/_jsx(SelectionEvent, {
|
|
193
267
|
hasChildren: hasChildren,
|
|
194
268
|
rowSelection: rowSelection,
|
|
@@ -201,7 +275,9 @@ var Table = function Table(_ref) {
|
|
|
201
275
|
}), /*#__PURE__*/_jsx(SheetEvent, {
|
|
202
276
|
name: "reverse",
|
|
203
277
|
handler: handleReverse
|
|
204
|
-
}, "_reverse"),
|
|
278
|
+
}, "_reverse"), /*#__PURE__*/_jsx(RemarkEvent, {
|
|
279
|
+
handler: handleCellClick
|
|
280
|
+
}), Object.keys(eventHandler || {}).map(function (key) {
|
|
205
281
|
return /*#__PURE__*/_jsx(SheetEvent, {
|
|
206
282
|
name: key,
|
|
207
283
|
handler: eventHandler === null || eventHandler === void 0 ? void 0 : eventHandler[key]
|
|
@@ -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,13 @@
|
|
|
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
|
+
// const handleClick = useCallback((value: SheetType.CellPosition) => {
|
|
6
|
+
// if (!value) return;
|
|
7
|
+
// console.log(value);
|
|
8
|
+
// }, []);
|
|
9
|
+
return /*#__PURE__*/_jsx(SheetEvent, {
|
|
10
|
+
name: "cell-select-single",
|
|
11
|
+
handler: handler
|
|
12
|
+
}, "cell-select-single");
|
|
13
|
+
};
|
|
@@ -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[][];
|
|
@@ -16,7 +16,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
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) {
|
|
@@ -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) {
|
|
@@ -147,8 +148,9 @@ export var formatGroupData = function formatGroupData(param) {
|
|
|
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,5 +1,5 @@
|
|
|
1
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
5
|
}) => any[][];
|
|
@@ -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 { 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,
|
|
@@ -1,16 +1,28 @@
|
|
|
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
|
+
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(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); }
|
|
1
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
8
|
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
|
-
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
|
-
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
9
|
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
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
+
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."); }
|
|
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
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
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; }
|
|
7
17
|
import { getNumberEditor, getSelectEditor, Table } from "./..";
|
|
8
|
-
import { Button } from 'antd';
|
|
18
|
+
import { Button, message } from 'antd';
|
|
9
19
|
import { isNil } from 'lodash';
|
|
10
|
-
import { useCallback, useState } from 'react';
|
|
20
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
11
21
|
import { SwitchViewer } from "../core/viewer";
|
|
12
22
|
import { SheetType } from "../type";
|
|
13
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
26
|
var RateValueInput = getNumberEditor({
|
|
15
27
|
addonAfter: '%',
|
|
16
28
|
min: 0,
|
|
@@ -38,7 +50,8 @@ var data = [{
|
|
|
38
50
|
gfaUnitPrice: 107350.31545913525,
|
|
39
51
|
nlaUnitPrice: 90130.38038659678,
|
|
40
52
|
totalValuation: 1622707368.4802885,
|
|
41
|
-
isEnabled: true
|
|
53
|
+
isEnabled: true,
|
|
54
|
+
remarks: ['valuationType', 'vacancyDiscountRate']
|
|
42
55
|
}, {
|
|
43
56
|
id: 2444,
|
|
44
57
|
draftId: '101601',
|
|
@@ -51,8 +64,165 @@ var data = [{
|
|
|
51
64
|
gfaUnitPrice: 89327.04427210477,
|
|
52
65
|
nlaUnitPrice: 89327.04427210477,
|
|
53
66
|
totalValuation: 1429232708.3536763,
|
|
67
|
+
remarks: ['termDiscountRate', 'vacancyDiscountRate'],
|
|
54
68
|
isEnabled: false
|
|
55
|
-
}
|
|
69
|
+
}, {
|
|
70
|
+
id: 2445,
|
|
71
|
+
draftId: '101601',
|
|
72
|
+
valuationType: 5,
|
|
73
|
+
termDiscountRate: 4.5,
|
|
74
|
+
reversionDiscountRate: 5.5,
|
|
75
|
+
vacancyDiscountRate: 5.5,
|
|
76
|
+
discountRate: null,
|
|
77
|
+
exitCapRate: null,
|
|
78
|
+
gfaUnitPrice: 89327.04427210477,
|
|
79
|
+
nlaUnitPrice: 89327.04427210477,
|
|
80
|
+
totalValuation: 1429232708.3536763,
|
|
81
|
+
remarks: ['reversionDiscountRate', 'vacancyDiscountRate'],
|
|
82
|
+
isEnabled: false
|
|
83
|
+
}, {
|
|
84
|
+
id: 2446,
|
|
85
|
+
draftId: '101601',
|
|
86
|
+
valuationType: 5,
|
|
87
|
+
termDiscountRate: 4.5,
|
|
88
|
+
reversionDiscountRate: 5.5,
|
|
89
|
+
vacancyDiscountRate: 5.5,
|
|
90
|
+
discountRate: null,
|
|
91
|
+
exitCapRate: null,
|
|
92
|
+
gfaUnitPrice: 89327.04427210477,
|
|
93
|
+
nlaUnitPrice: 89327.04427210477,
|
|
94
|
+
totalValuation: 1429232708.3536763,
|
|
95
|
+
remarks: ['vacancyDiscountRate'],
|
|
96
|
+
isEnabled: false
|
|
97
|
+
}, {
|
|
98
|
+
id: 2447,
|
|
99
|
+
draftId: '101601',
|
|
100
|
+
valuationType: 5,
|
|
101
|
+
termDiscountRate: 4.5,
|
|
102
|
+
reversionDiscountRate: 5.5,
|
|
103
|
+
vacancyDiscountRate: 5.5,
|
|
104
|
+
discountRate: null,
|
|
105
|
+
exitCapRate: null,
|
|
106
|
+
gfaUnitPrice: 89327.04427210477,
|
|
107
|
+
nlaUnitPrice: 89327.04427210477,
|
|
108
|
+
totalValuation: 1429232708.3536763,
|
|
109
|
+
remarks: ['discountRate', 'vacancyDiscountRate'],
|
|
110
|
+
isEnabled: false
|
|
111
|
+
}, {
|
|
112
|
+
id: 2448,
|
|
113
|
+
draftId: '101601',
|
|
114
|
+
valuationType: 5,
|
|
115
|
+
termDiscountRate: 4.5,
|
|
116
|
+
reversionDiscountRate: 5.5,
|
|
117
|
+
vacancyDiscountRate: 5.5,
|
|
118
|
+
discountRate: null,
|
|
119
|
+
exitCapRate: null,
|
|
120
|
+
gfaUnitPrice: 89327.04427210477,
|
|
121
|
+
nlaUnitPrice: 89327.04427210477,
|
|
122
|
+
totalValuation: 1429232708.3536763,
|
|
123
|
+
remarks: ['exitCapRate', 'vacancyDiscountRate'],
|
|
124
|
+
isEnabled: false
|
|
125
|
+
}, {
|
|
126
|
+
id: 2449,
|
|
127
|
+
draftId: '101601',
|
|
128
|
+
valuationType: 5,
|
|
129
|
+
termDiscountRate: 4.5,
|
|
130
|
+
reversionDiscountRate: 5.5,
|
|
131
|
+
vacancyDiscountRate: 5.5,
|
|
132
|
+
discountRate: null,
|
|
133
|
+
exitCapRate: null,
|
|
134
|
+
gfaUnitPrice: 89327.04427210477,
|
|
135
|
+
nlaUnitPrice: 89327.04427210477,
|
|
136
|
+
totalValuation: 1429232708.3536763,
|
|
137
|
+
remarks: ['gfaUnitPrice', 'vacancyDiscountRate'],
|
|
138
|
+
isEnabled: false
|
|
139
|
+
}, {
|
|
140
|
+
id: 2450,
|
|
141
|
+
draftId: '101601',
|
|
142
|
+
valuationType: 5,
|
|
143
|
+
termDiscountRate: 4.5,
|
|
144
|
+
reversionDiscountRate: 5.5,
|
|
145
|
+
vacancyDiscountRate: 5.5,
|
|
146
|
+
discountRate: null,
|
|
147
|
+
exitCapRate: null,
|
|
148
|
+
gfaUnitPrice: 89327.04427210477,
|
|
149
|
+
nlaUnitPrice: 89327.04427210477,
|
|
150
|
+
totalValuation: 1429232708.3536763,
|
|
151
|
+
remarks: ['nlaUnitPrice', 'vacancyDiscountRate'],
|
|
152
|
+
isEnabled: false
|
|
153
|
+
}, {
|
|
154
|
+
id: 2451,
|
|
155
|
+
draftId: '101601',
|
|
156
|
+
valuationType: 5,
|
|
157
|
+
termDiscountRate: 4.5,
|
|
158
|
+
reversionDiscountRate: 5.5,
|
|
159
|
+
vacancyDiscountRate: 5.5,
|
|
160
|
+
discountRate: null,
|
|
161
|
+
exitCapRate: null,
|
|
162
|
+
gfaUnitPrice: 89327.04427210477,
|
|
163
|
+
nlaUnitPrice: 89327.04427210477,
|
|
164
|
+
totalValuation: 1429232708.3536763,
|
|
165
|
+
remarks: ['totalValuation', 'vacancyDiscountRate'],
|
|
166
|
+
isEnabled: false
|
|
167
|
+
}, {
|
|
168
|
+
id: 2452,
|
|
169
|
+
draftId: '101601',
|
|
170
|
+
valuationType: 5,
|
|
171
|
+
termDiscountRate: 4.5,
|
|
172
|
+
reversionDiscountRate: 5.5,
|
|
173
|
+
vacancyDiscountRate: 5.5,
|
|
174
|
+
discountRate: null,
|
|
175
|
+
exitCapRate: null,
|
|
176
|
+
gfaUnitPrice: 89327.04427210477,
|
|
177
|
+
nlaUnitPrice: 89327.04427210477,
|
|
178
|
+
totalValuation: 1429232708.3536763,
|
|
179
|
+
remarks: ['termDiscountRate', 'vacancyDiscountRate'],
|
|
180
|
+
isEnabled: false
|
|
181
|
+
}, {
|
|
182
|
+
id: 2453,
|
|
183
|
+
draftId: '101601',
|
|
184
|
+
valuationType: 5,
|
|
185
|
+
termDiscountRate: 4.5,
|
|
186
|
+
reversionDiscountRate: 5.5,
|
|
187
|
+
vacancyDiscountRate: 5.5,
|
|
188
|
+
discountRate: null,
|
|
189
|
+
exitCapRate: null,
|
|
190
|
+
gfaUnitPrice: 89327.04427210477,
|
|
191
|
+
nlaUnitPrice: 89327.04427210477,
|
|
192
|
+
totalValuation: 1429232708.3536763,
|
|
193
|
+
remarks: ['termDiscountRate', 'vacancyDiscountRate'],
|
|
194
|
+
isEnabled: false
|
|
195
|
+
}, {
|
|
196
|
+
id: 2454,
|
|
197
|
+
draftId: '101601',
|
|
198
|
+
valuationType: 5,
|
|
199
|
+
termDiscountRate: 4.5,
|
|
200
|
+
reversionDiscountRate: 5.5,
|
|
201
|
+
vacancyDiscountRate: 5.5,
|
|
202
|
+
discountRate: null,
|
|
203
|
+
exitCapRate: null,
|
|
204
|
+
gfaUnitPrice: 89327.04427210477,
|
|
205
|
+
nlaUnitPrice: 89327.04427210477,
|
|
206
|
+
totalValuation: 1429232708.3536763,
|
|
207
|
+
remarks: ['termDiscountRate', 'vacancyDiscountRate'],
|
|
208
|
+
isEnabled: false
|
|
209
|
+
}].concat(_toConsumableArray(Array(100).fill(0).map(function (item, i) {
|
|
210
|
+
return {
|
|
211
|
+
id: 2455 + i,
|
|
212
|
+
draftId: '101601',
|
|
213
|
+
valuationType: 5,
|
|
214
|
+
termDiscountRate: 4.5,
|
|
215
|
+
reversionDiscountRate: 5.5,
|
|
216
|
+
vacancyDiscountRate: 5.5,
|
|
217
|
+
discountRate: null,
|
|
218
|
+
exitCapRate: null,
|
|
219
|
+
gfaUnitPrice: 89327.04427210477,
|
|
220
|
+
nlaUnitPrice: 89327.04427210477,
|
|
221
|
+
totalValuation: 1429232708.3536763,
|
|
222
|
+
remarks: ['termDiscountRate', 'vacancyDiscountRate'],
|
|
223
|
+
isEnabled: false
|
|
224
|
+
};
|
|
225
|
+
})));
|
|
56
226
|
var evaluateMethods = [{
|
|
57
227
|
label: 'DCF',
|
|
58
228
|
value: 2
|
|
@@ -168,6 +338,36 @@ export default (function () {
|
|
|
168
338
|
width: 134,
|
|
169
339
|
editor: ValueInput,
|
|
170
340
|
readonly: true
|
|
341
|
+
}, {
|
|
342
|
+
title: 'id-1',
|
|
343
|
+
dataIndex: 'id-1',
|
|
344
|
+
width: 134,
|
|
345
|
+
editor: ValueInput,
|
|
346
|
+
readonly: true
|
|
347
|
+
}, {
|
|
348
|
+
title: 'id-2',
|
|
349
|
+
dataIndex: 'id-2',
|
|
350
|
+
width: 134,
|
|
351
|
+
editor: ValueInput,
|
|
352
|
+
readonly: true
|
|
353
|
+
}, {
|
|
354
|
+
title: 'id-3',
|
|
355
|
+
dataIndex: 'id-3',
|
|
356
|
+
width: 134,
|
|
357
|
+
editor: ValueInput,
|
|
358
|
+
readonly: true
|
|
359
|
+
}, {
|
|
360
|
+
title: 'id-4',
|
|
361
|
+
dataIndex: 'id-4',
|
|
362
|
+
width: 134,
|
|
363
|
+
editor: ValueInput,
|
|
364
|
+
readonly: true
|
|
365
|
+
}, {
|
|
366
|
+
title: 'id-5',
|
|
367
|
+
dataIndex: 'id-5',
|
|
368
|
+
width: 134,
|
|
369
|
+
editor: ValueInput,
|
|
370
|
+
readonly: true
|
|
171
371
|
}, {
|
|
172
372
|
title: '操作',
|
|
173
373
|
width: 62,
|
|
@@ -217,10 +417,85 @@ export default (function () {
|
|
|
217
417
|
// return <div className="value-viewer number-value-viewer" />;
|
|
218
418
|
// },
|
|
219
419
|
}];
|
|
420
|
+
var sheetInstance = useRef(null);
|
|
220
421
|
var handleChange = useCallback(function () {}, [state]);
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
422
|
+
useEffect(function () {
|
|
423
|
+
setTimeout(function () {
|
|
424
|
+
var _sheetInstance$curren;
|
|
425
|
+
(_sheetInstance$curren = sheetInstance.current) === null || _sheetInstance$curren === void 0 || _sheetInstance$curren.select({
|
|
426
|
+
start: {
|
|
427
|
+
row: 1,
|
|
428
|
+
col: 3
|
|
429
|
+
},
|
|
430
|
+
end: {
|
|
431
|
+
row: 1,
|
|
432
|
+
col: 3
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
}, 3);
|
|
436
|
+
}, []);
|
|
437
|
+
var renderRemark = useCallback(function (value) {
|
|
438
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
439
|
+
children: [/*#__PURE__*/_jsxs("p", {
|
|
440
|
+
children: [" columns:", value.columnKey]
|
|
441
|
+
}), /*#__PURE__*/_jsxs("p", {
|
|
442
|
+
children: [" id:", value.id]
|
|
443
|
+
}), /*#__PURE__*/_jsx("p", {
|
|
444
|
+
children: " bugs --"
|
|
445
|
+
})]
|
|
446
|
+
});
|
|
447
|
+
}, []);
|
|
448
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
449
|
+
style: {
|
|
450
|
+
height: '100vh',
|
|
451
|
+
padding: '29vh 0',
|
|
452
|
+
overflow: 'auto',
|
|
453
|
+
background: 'rgba(255,255,0,.2)'
|
|
454
|
+
},
|
|
455
|
+
children: [/*#__PURE__*/_jsx(Table, {
|
|
456
|
+
virtualized: true,
|
|
457
|
+
draggable: true,
|
|
458
|
+
sheetInstance: sheetInstance,
|
|
459
|
+
columns: columns,
|
|
460
|
+
showRemark: true,
|
|
461
|
+
remarkRender: renderRemark,
|
|
462
|
+
handleAddRemark: function handleAddRemark(value) {
|
|
463
|
+
message.info("".concat(value.id, "\uFF1A").concat(value.columnKey));
|
|
464
|
+
console.log(value.id, value.columnKey);
|
|
465
|
+
},
|
|
466
|
+
dataSource: state,
|
|
467
|
+
onChange: handleChange,
|
|
468
|
+
onContextMenu: function onContextMenu() {},
|
|
469
|
+
menuRenderer: function menuRenderer(props) {
|
|
470
|
+
var handleMenu = props.onContextMenu,
|
|
471
|
+
cell = props.cell,
|
|
472
|
+
position = props.position,
|
|
473
|
+
children = props.children;
|
|
474
|
+
if (!cell || !handleMenu || cell.col < 1 || !position) {
|
|
475
|
+
return null;
|
|
476
|
+
}
|
|
477
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
478
|
+
className: "harvest-menu",
|
|
479
|
+
style: _objectSpread(_objectSpread({}, position), {}, {
|
|
480
|
+
background: 'white'
|
|
481
|
+
}),
|
|
482
|
+
children: [children, /*#__PURE__*/_jsx("div", {
|
|
483
|
+
className: "harvest-menu-item",
|
|
484
|
+
children: "\u5411\u4E0B\u586B\u5145"
|
|
485
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
486
|
+
className: "harvest-menu-item",
|
|
487
|
+
children: "\u5411\u53F3\u586B\u5145"
|
|
488
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
489
|
+
className: "harvest-menu-item",
|
|
490
|
+
children: "\u5168\u90E8\u586B\u5145"
|
|
491
|
+
})]
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
495
|
+
style: {
|
|
496
|
+
height: '100vh'
|
|
497
|
+
},
|
|
498
|
+
children: " empty"
|
|
499
|
+
})]
|
|
225
500
|
});
|
|
226
501
|
});
|
package/dist/type/sheet.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { EventEmitter } from 'events';
|
|
3
|
-
import { CSSProperties } from 'react';
|
|
3
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
4
4
|
import { SheetTableType, SheetType } from '.';
|
|
5
5
|
export declare enum CellAlign {
|
|
6
6
|
left = "left",
|
|
@@ -92,6 +92,7 @@ export type MenuRenderProps = {
|
|
|
92
92
|
};
|
|
93
93
|
cell?: CellPosition;
|
|
94
94
|
onContextMenu?: (event: any) => void;
|
|
95
|
+
children?: ReactNode | ReactNode[];
|
|
95
96
|
};
|
|
96
97
|
export type SheetInstance = {
|
|
97
98
|
zoomTo: (row?: number) => void;
|
|
@@ -119,6 +120,7 @@ export type SheetProps = {
|
|
|
119
120
|
searchStyle?: Partial<CSSProperties>;
|
|
120
121
|
sticky?: boolean;
|
|
121
122
|
groupConfig?: RowGroupConfig;
|
|
123
|
+
remarkElement?: ReactNode;
|
|
122
124
|
onCellsChanged?: CellChangeHandler;
|
|
123
125
|
menuRenderer?: React.FC<MenuRenderProps>;
|
|
124
126
|
onContextMenu?: (event: any) => void;
|
|
@@ -132,6 +134,7 @@ export type SheetProps = {
|
|
|
132
134
|
boldScroll?: boolean;
|
|
133
135
|
hideColBar?: boolean;
|
|
134
136
|
showQuickLocationBtn?: boolean;
|
|
137
|
+
showRemark?: boolean;
|
|
135
138
|
ControlContainer?: React.FC;
|
|
136
139
|
};
|
|
137
140
|
export type WidthConfigContext = {
|
|
@@ -146,6 +149,7 @@ export type GroupConfigContext = {
|
|
|
146
149
|
};
|
|
147
150
|
export type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
|
|
148
151
|
className?: string;
|
|
152
|
+
dragable?: boolean;
|
|
149
153
|
showGroup?: boolean;
|
|
150
154
|
showSelect?: boolean;
|
|
151
155
|
controlWidth?: number;
|
|
@@ -80,7 +80,19 @@ export type TableProps = {
|
|
|
80
80
|
sticky?: boolean;
|
|
81
81
|
draggable?: boolean;
|
|
82
82
|
freePaste?: boolean;
|
|
83
|
+
freeze?: boolean;
|
|
83
84
|
showBackEdit?: boolean;
|
|
85
|
+
showRemark?: boolean;
|
|
86
|
+
remarkRender?: (props: {
|
|
87
|
+
cell: SheetType.CellPosition;
|
|
88
|
+
columnKey: string;
|
|
89
|
+
id?: string | number;
|
|
90
|
+
}) => ReactNode;
|
|
91
|
+
handleAddRemark?: (value: {
|
|
92
|
+
cell: SheetType.CellPosition;
|
|
93
|
+
columnKey: string;
|
|
94
|
+
id?: string | number;
|
|
95
|
+
}) => void;
|
|
84
96
|
backEditStyle?: Partial<CSSProperties>;
|
|
85
97
|
searchStyle?: Partial<CSSProperties>;
|
|
86
98
|
rowSelection?: TableRowSelection;
|