@zhenliang/sheet 0.1.7-3.beta.7 → 0.1.7-3.beta.8
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],
|
|
@@ -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>[];
|