@zhenliang/sheet 0.1.7-3.beta.7 → 0.1.7-3.beta.9
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.
|
@@ -5,7 +5,7 @@ export var Remark = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
5
5
|
children = props.children,
|
|
6
6
|
position = props.position;
|
|
7
7
|
var transform = useMemo(function () {
|
|
8
|
-
var rightOverflow = document.body.clientWidth - position.left <
|
|
8
|
+
var rightOverflow = document.body.clientWidth - position.left < 400;
|
|
9
9
|
var bottomOverflow = document.body.clientHeight - position.top < 400;
|
|
10
10
|
if (rightOverflow && bottomOverflow) {
|
|
11
11
|
return "translate(-100%, -100%)";
|
package/dist/core/table/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { Sheet, useSetState } from "../..";
|
|
|
17
17
|
import { GroupContext } from "../../hooks/useGroupConfig";
|
|
18
18
|
import { WidthContext } from "../../hooks/useWidthConfig";
|
|
19
19
|
import { ConfigProvider, Empty } from 'antd';
|
|
20
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
20
|
+
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
21
21
|
import { SheetEvent } from "../sheet/Event";
|
|
22
22
|
import { DraggableShell } from "../shell/draggableShell";
|
|
23
23
|
import { TableShell } from "../shell/tableShell";
|
|
@@ -57,7 +57,7 @@ var Table = function Table(_ref) {
|
|
|
57
57
|
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
58
58
|
widths = _useSetState2[0],
|
|
59
59
|
setWidth = _useSetState2[1];
|
|
60
|
-
var sheetInstance =
|
|
60
|
+
var sheetInstance = _sheetInstance;
|
|
61
61
|
var dataHasChildren = dataSource === null || dataSource === void 0 ? void 0 : dataSource.some(function (item) {
|
|
62
62
|
var _item$children;
|
|
63
63
|
return (item === null || item === void 0 || (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) > 0;
|
|
@@ -66,6 +66,36 @@ var Table = function Table(_ref) {
|
|
|
66
66
|
var hasChildren = dataHasChildren || configWithChildren;
|
|
67
67
|
var hasControl = hasChildren || !!rowSelection;
|
|
68
68
|
var offset = hasControl ? 2 : 1;
|
|
69
|
+
useImperativeHandle(sheetRef, function () {
|
|
70
|
+
return new Proxy({}, {
|
|
71
|
+
get: function get(target, property) {
|
|
72
|
+
var _sheetInstance$curren3;
|
|
73
|
+
if (property === 'goToByTable') {
|
|
74
|
+
return function (id, columnKey) {
|
|
75
|
+
var _sheetInstance$curren, _sheetInstance$curren2;
|
|
76
|
+
var toCol = columns.findIndex(function (column) {
|
|
77
|
+
return column.dataIndex === columnKey;
|
|
78
|
+
}) + offset;
|
|
79
|
+
var toRow = data.findIndex(function (d) {
|
|
80
|
+
return String(d === null || d === void 0 ? void 0 : d[0].id) === String(id);
|
|
81
|
+
});
|
|
82
|
+
(_sheetInstance$curren = sheetInstance.current) === null || _sheetInstance$curren === void 0 || _sheetInstance$curren.goTo(toRow, toCol);
|
|
83
|
+
(_sheetInstance$curren2 = sheetInstance.current) === null || _sheetInstance$curren2 === void 0 || _sheetInstance$curren2.select({
|
|
84
|
+
start: {
|
|
85
|
+
row: toRow,
|
|
86
|
+
col: toCol
|
|
87
|
+
},
|
|
88
|
+
end: {
|
|
89
|
+
row: toRow,
|
|
90
|
+
col: toCol
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return (_sheetInstance$curren3 = sheetInstance.current) === null || _sheetInstance$curren3 === void 0 ? void 0 : _sheetInstance$curren3[property];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}, [columns, data]);
|
|
69
99
|
var _useRowSelection = useRowSelection(dataSource, rowSelection, hasChildren),
|
|
70
100
|
_useRowSelection2 = _slicedToArray(_useRowSelection, 2),
|
|
71
101
|
checkedRow = _useRowSelection2[0],
|
|
@@ -230,7 +260,7 @@ var Table = function Table(_ref) {
|
|
|
230
260
|
if (!menuRenderer) {
|
|
231
261
|
if (showRemark) {
|
|
232
262
|
return function (props) {
|
|
233
|
-
var _data$row3;
|
|
263
|
+
var _data$row3, _target$record, _target$record$includ;
|
|
234
264
|
var cell = props.cell;
|
|
235
265
|
var _ref5 = cell !== null && cell !== void 0 ? cell : {},
|
|
236
266
|
_ref5$col = _ref5.col,
|
|
@@ -238,7 +268,8 @@ var Table = function Table(_ref) {
|
|
|
238
268
|
_ref5$row = _ref5.row,
|
|
239
269
|
row = _ref5$row === void 0 ? -1 : _ref5$row;
|
|
240
270
|
var target = data === null || data === void 0 || (_data$row3 = data[row]) === null || _data$row3 === void 0 ? void 0 : _data$row3[col + 1];
|
|
241
|
-
|
|
271
|
+
var cellHasRemark = (_target$record = target.record) === null || _target$record === void 0 || (_target$record = _target$record.remarks) === null || _target$record === void 0 || (_target$record$includ = _target$record.includes) === null || _target$record$includ === void 0 ? void 0 : _target$record$includ.call(_target$record, target.dataIndex);
|
|
272
|
+
if ((target === null || target === void 0 ? void 0 : target.readonly) !== true && !target.fixed && !cellHasRemark) {
|
|
242
273
|
return /*#__PURE__*/_jsx("div", {
|
|
243
274
|
className: "harvest-menu",
|
|
244
275
|
style: _objectSpread({}, props.position),
|
|
@@ -251,7 +282,7 @@ var Table = function Table(_ref) {
|
|
|
251
282
|
return undefined;
|
|
252
283
|
} else {
|
|
253
284
|
return function (props) {
|
|
254
|
-
var _data$row4;
|
|
285
|
+
var _data$row4, _target$record2, _target$record2$inclu;
|
|
255
286
|
var cell = props.cell;
|
|
256
287
|
var _ref6 = cell !== null && cell !== void 0 ? cell : {},
|
|
257
288
|
_ref6$col = _ref6.col,
|
|
@@ -260,7 +291,8 @@ var Table = function Table(_ref) {
|
|
|
260
291
|
row = _ref6$row === void 0 ? -1 : _ref6$row;
|
|
261
292
|
var target = data === null || data === void 0 || (_data$row4 = data[row]) === null || _data$row4 === void 0 ? void 0 : _data$row4[col + 1];
|
|
262
293
|
var MenuFC = menuRenderer;
|
|
263
|
-
|
|
294
|
+
var cellHasRemark = (_target$record2 = target.record) === null || _target$record2 === void 0 || (_target$record2 = _target$record2.remarks) === null || _target$record2 === void 0 || (_target$record2$inclu = _target$record2.includes) === null || _target$record2$inclu === void 0 ? void 0 : _target$record2$inclu.call(_target$record2, target.dataIndex);
|
|
295
|
+
if (showRemark && (target === null || target === void 0 ? void 0 : target.readonly) !== true && !target.fixed && !cellHasRemark) {
|
|
264
296
|
return /*#__PURE__*/_jsx(MenuFC, _objectSpread(_objectSpread({}, props), {}, {
|
|
265
297
|
target: target,
|
|
266
298
|
children: remarkMenu
|
|
@@ -62,6 +62,9 @@ export type RemarkProps = {
|
|
|
62
62
|
id?: string | number;
|
|
63
63
|
close: () => void;
|
|
64
64
|
};
|
|
65
|
+
export type TableInstance = {
|
|
66
|
+
goToByTable?: (id: number, columnKey: string) => void;
|
|
67
|
+
} & SheetType.SheetInstance;
|
|
65
68
|
export type TableProps = {
|
|
66
69
|
/**
|
|
67
70
|
* @description 表格类名
|
|
@@ -72,7 +75,7 @@ export type TableProps = {
|
|
|
72
75
|
* @description sheet的一些定义方法可执行
|
|
73
76
|
* @default "object"
|
|
74
77
|
*/
|
|
75
|
-
sheetInstance?: React.MutableRefObject<SheetType.SheetInstance | null>;
|
|
78
|
+
sheetInstance?: React.MutableRefObject<SheetType.SheetInstance & TableInstance | null>;
|
|
76
79
|
columns: ColumnProps[];
|
|
77
80
|
virtualized?: boolean;
|
|
78
81
|
dataSource: Record<string, unknown>[];
|