@zhenliang/sheet 0.1.7-3.beta.0 → 0.1.7-3.beta.10
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/cascaderEditor/index.js +2 -2
- package/dist/core/editor/dateEditor/index.js +2 -2
- package/dist/core/editor/numberEditor/index.js +2 -2
- package/dist/core/editor/selectEditor/index.js +4 -4
- package/dist/core/reducers/keyboardReducer.js +2 -1
- package/dist/core/reducers/mouseReducer.js +3 -2
- package/dist/core/reducers/sideEffectReducer.js +3 -3
- package/dist/core/sheet/Cell.d.ts +1 -1
- package/dist/core/sheet/Cell.js +3 -3
- package/dist/core/sheet/Control.d.ts +1 -1
- package/dist/core/sheet/Control.js +2 -2
- package/dist/core/sheet/DataEditor.js +2 -2
- package/dist/core/sheet/DefaultCell.js +1 -1
- package/dist/core/sheet/DefaultRow.js +2 -2
- package/dist/core/sheet/DefaultRowMapper.js +4 -4
- package/dist/core/sheet/DefaultShell.js +1 -1
- package/dist/core/sheet/Event.d.ts +1 -1
- package/dist/core/sheet/Event.js +1 -1
- package/dist/core/sheet/Menu.d.ts +1 -1
- package/dist/core/sheet/Menu.js +3 -3
- package/dist/core/sheet/Remark.d.ts +9 -0
- package/dist/core/sheet/Remark.js +32 -0
- package/dist/core/sheet/ValueViewer.js +1 -1
- package/dist/core/sheet/index.js +52 -14
- package/dist/core/sheet/index.less +34 -0
- package/dist/core/sheet/searchInput.d.ts +1 -1
- package/dist/core/sheet/searchInput.js +3 -3
- package/dist/core/sheet/useCellEvent.js +1 -1
- package/dist/core/sheet/useContextMenu.js +4 -4
- package/dist/core/sheet/useMouseEvent.js +1 -1
- package/dist/core/sheet/useRemarkContainer.d.ts +14 -0
- package/dist/core/sheet/useRemarkContainer.js +121 -0
- package/dist/core/sheet/useSearchInput.js +1 -1
- package/dist/core/sheet/useSelectVisible.js +1 -1
- package/dist/core/sheet/useVirtualList.js +2 -2
- package/dist/core/shell/draggableShell/index.d.ts +1 -1
- package/dist/core/shell/draggableShell/index.js +10 -5
- package/dist/core/shell/tableShell.d.ts +2 -2
- package/dist/core/shell/tableShell.js +11 -155
- package/dist/core/table/addButton.d.ts +1 -2
- package/dist/core/table/addButton.js +3 -4
- package/dist/core/table/events.d.ts +1 -1
- package/dist/core/table/events.js +3 -3
- package/dist/core/table/index.d.ts +1 -0
- package/dist/core/table/index.js +164 -12
- package/dist/core/table/index.less +19 -0
- package/dist/core/table/remarkEvent.d.ts +5 -0
- package/dist/core/table/remarkEvent.js +9 -0
- package/dist/core/table/useGroupConfig.d.ts +1 -1
- package/dist/core/table/useGroupConfig.js +7 -5
- package/dist/core/table/useRowSelection.d.ts +1 -1
- package/dist/core/table/useRowSelection.js +7 -4
- package/dist/core/viewer/btnViewer/index.js +3 -3
- package/dist/core/viewer/cascaderViewer/index.js +2 -2
- package/dist/core/viewer/checkViewer/index.js +2 -2
- package/dist/core/viewer/editViewer/index.js +3 -3
- package/dist/core/viewer/groupViewer/index.js +2 -2
- package/dist/core/viewer/selectorViewer/index.js +1 -1
- package/dist/core/viewer/switchViewer/index.js +2 -2
- package/dist/example/antComponent.d.ts +1 -1
- package/dist/example/antComponent.js +2 -2
- package/dist/example/basic.d.ts +1 -1
- package/dist/example/basic.js +4 -4
- package/dist/example/ellipsis.d.ts +1 -1
- package/dist/example/ellipsis.js +2 -2
- package/dist/example/fixed.d.ts +1 -1
- package/dist/example/fixed.js +2 -2
- package/dist/example/group.js +2 -2
- package/dist/example/selection.d.ts +1 -1
- package/dist/example/selection.js +2 -2
- package/dist/example/sheet.d.ts +1 -1
- package/dist/example/sheet.js +3 -3
- package/dist/example/valuationAnalyze.js +356 -13
- package/dist/hooks/useEventBus.js +1 -1
- package/dist/hooks/useGroupConfig.d.ts +1 -1
- package/dist/hooks/useGroupConfig.js +2 -2
- package/dist/hooks/useKeyboard.js +1 -1
- package/dist/hooks/useMiddlewareReducer.js +1 -1
- package/dist/hooks/useMouse.js +1 -1
- package/dist/hooks/useSetState.js +1 -1
- package/dist/hooks/useSheetEvent.d.ts +1 -1
- package/dist/hooks/useSheetEvent.js +2 -2
- package/dist/hooks/useWidthConfig.d.ts +1 -1
- package/dist/hooks/useWidthConfig.js +2 -2
- package/dist/type/sheet.d.ts +8 -1
- package/dist/type/sheetTable.d.ts +15 -2
- package/package.json +4 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Cascader } from 'antd';
|
|
2
2
|
import 'antd/es/cascader/style/index.css';
|
|
3
3
|
import { isNil } from 'lodash';
|
|
4
|
-
import { useMemo } from
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
5
|
import { optionsToValuesFromLabelOrValue, valuesTransferToLabel } from "../../util";
|
|
6
6
|
import "./index.less";
|
|
7
|
-
import { jsx as _jsx } from "
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
var getCascaderEditor = function getCascaderEditor(options, getCustomOptions) {
|
|
9
9
|
var CascaderEditor = function CascaderEditor(props) {
|
|
10
10
|
var value = props.value,
|
|
@@ -8,9 +8,9 @@ import { DatePicker } from 'antd';
|
|
|
8
8
|
import 'antd/es/date-picker/style/index.css';
|
|
9
9
|
import { isNil } from 'lodash';
|
|
10
10
|
import moment from 'moment';
|
|
11
|
-
import { useEffect, useMemo, useRef } from
|
|
11
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
12
12
|
import "./index.less";
|
|
13
|
-
import { jsx as _jsx } from "
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
export var getDateEditor = function getDateEditor(dateProps) {
|
|
15
15
|
var DateEditor = function DateEditor(props) {
|
|
16
16
|
var value = props.value,
|
|
@@ -11,9 +11,9 @@ import { formatPrecision } from "../../../standardUtils";
|
|
|
11
11
|
import { InputNumber as AntInputNumber } from 'antd';
|
|
12
12
|
import 'antd/es/input-number/style/index.css';
|
|
13
13
|
import { isNil, isNumber } from 'lodash';
|
|
14
|
-
import { useCallback, useEffect, useRef } from
|
|
14
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
15
15
|
import "./index.less";
|
|
16
|
-
import { jsx as _jsx } from "
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
17
|
var isNumeric = function isNumeric(str) {
|
|
18
18
|
// 使用正则表达式匹配数字,包括整数和小数
|
|
19
19
|
return /^-?\d+(\.\d+)?$/.test(str);
|
|
@@ -15,11 +15,11 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
15
15
|
import { Select } from 'antd';
|
|
16
16
|
import 'antd/es/select/style/index.css';
|
|
17
17
|
import { isNil } from 'lodash';
|
|
18
|
-
import { useState } from
|
|
18
|
+
import { useState } from 'react';
|
|
19
19
|
import "./index.less";
|
|
20
|
-
import { Fragment as _Fragment } from "
|
|
21
|
-
import { jsx as _jsx } from "
|
|
22
|
-
import { jsxs as _jsxs } from "
|
|
20
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
23
|
export var getSelectEditor = function getSelectEditor(options) {
|
|
24
24
|
var valueKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
|
|
25
25
|
var extra = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : /*#__PURE__*/_jsx(_Fragment, {});
|
|
@@ -71,7 +71,8 @@ export var keyboardReducer = {
|
|
|
71
71
|
end = state.end,
|
|
72
72
|
editing = state.editing,
|
|
73
73
|
data = state.data;
|
|
74
|
-
|
|
74
|
+
var freeze = state.freeze;
|
|
75
|
+
if (!start || !end || data !== null && data !== void 0 && (_data$start$row = data[start.row]) !== null && _data$start$row !== void 0 && _data$start$row[start.col].readonly || !(data !== null && data !== void 0 && (_data$start$row2 = data[start.row]) !== null && _data$start$row2 !== void 0 && _data$start$row2[start.col].editable) || freeze) {
|
|
75
76
|
return state;
|
|
76
77
|
}
|
|
77
78
|
if (!editing) {
|
|
@@ -164,8 +164,9 @@ export var mouseReducer = {
|
|
|
164
164
|
var _ref4 = payload,
|
|
165
165
|
row = _ref4.row,
|
|
166
166
|
col = _ref4.col;
|
|
167
|
-
var data = state.data
|
|
168
|
-
|
|
167
|
+
var data = state.data,
|
|
168
|
+
freeze = state.freeze;
|
|
169
|
+
if (data !== null && data !== void 0 && (_data$row$col = data[row][col]) !== null && _data$row$col !== void 0 && _data$row$col.readonly || freeze) {
|
|
169
170
|
return state;
|
|
170
171
|
}
|
|
171
172
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -206,12 +206,12 @@ export var sideEffectReducer = {
|
|
|
206
206
|
paste: function paste(dispatch, getState) {
|
|
207
207
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
208
208
|
var _extChanges$;
|
|
209
|
-
var _getState8, start, end, cellChangeHandler, history, _getState8$freePaste, freePaste, data, groupConfig, pasteData, changeInfo, changes, extChanges, legalChanges, lastRow, lastIndex, legalExtChanges, newHistory;
|
|
209
|
+
var _getState8, start, end, cellChangeHandler, history, _getState8$freePaste, freePaste, data, freeze, groupConfig, pasteData, changeInfo, changes, extChanges, legalChanges, lastRow, lastIndex, legalExtChanges, newHistory;
|
|
210
210
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
211
211
|
while (1) switch (_context.prev = _context.next) {
|
|
212
212
|
case 0:
|
|
213
|
-
_getState8 = getState(), start = _getState8.start, end = _getState8.end, cellChangeHandler = _getState8.cellChangeHandler, history = _getState8.history, _getState8$freePaste = _getState8.freePaste, freePaste = _getState8$freePaste === void 0 ? false : _getState8$freePaste, data = _getState8.data, groupConfig = _getState8.groupConfig;
|
|
214
|
-
if (!(!start || !end)) {
|
|
213
|
+
_getState8 = getState(), start = _getState8.start, end = _getState8.end, cellChangeHandler = _getState8.cellChangeHandler, history = _getState8.history, _getState8$freePaste = _getState8.freePaste, freePaste = _getState8$freePaste === void 0 ? false : _getState8$freePaste, data = _getState8.data, freeze = _getState8.freeze, groupConfig = _getState8.groupConfig;
|
|
214
|
+
if (!(!start || !end || freeze)) {
|
|
215
215
|
_context.next = 3;
|
|
216
216
|
break;
|
|
217
217
|
}
|
package/dist/core/sheet/Cell.js
CHANGED
|
@@ -5,13 +5,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
5
5
|
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
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import { isNil } from 'lodash';
|
|
8
|
-
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from
|
|
8
|
+
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
9
|
import { useSetState, useSheetEvent } from "../../hooks";
|
|
10
10
|
import { renderValue } from "../util";
|
|
11
11
|
import DataEditor from "./DataEditor";
|
|
12
12
|
import DefaultCell from "./DefaultCell";
|
|
13
13
|
import ValueViewer from "./ValueViewer";
|
|
14
|
-
import { jsx as _jsx } from "
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
function initialData(_ref) {
|
|
16
16
|
var cell = _ref.cell;
|
|
17
17
|
return renderValue(cell);
|
|
@@ -184,7 +184,7 @@ var Cell = function Cell(props) {
|
|
|
184
184
|
children: content
|
|
185
185
|
});
|
|
186
186
|
};
|
|
187
|
-
export default memo(Cell, function (pre, next) {
|
|
187
|
+
export default /*#__PURE__*/memo(Cell, function (pre, next) {
|
|
188
188
|
var shouldUpdate = pre.col === next.col && pre.row === next.row && pre.cell.value === next.cell.value && pre.cell.dataEditor === next.cell.dataEditor && pre.cell.className === next.cell.className && pre.cell.record === next.cell.record && pre.cellFixedInfo === next.cellFixedInfo;
|
|
189
189
|
return shouldUpdate;
|
|
190
190
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EditOutlined, VerticalAlignBottomOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
|
|
2
2
|
import { Button, Tooltip } from 'antd';
|
|
3
|
-
import React, { useMemo } from
|
|
4
|
-
import { jsx as _jsx } from "
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
var itemStyle = {
|
|
6
6
|
fontSize: 18,
|
|
7
7
|
marginTop: 2
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useEffect, useRef } from
|
|
2
|
-
import { jsx as _jsx } from "
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
var DataEditor = function DataEditor(_ref) {
|
|
4
4
|
var value = _ref.value,
|
|
5
5
|
onChange = _ref.onChange;
|
|
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
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
7
|
import { classNames } from "../util";
|
|
8
|
-
import { jsx as _jsx } from "
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
var DefaultCell = function DefaultCell(props) {
|
|
10
10
|
var cell = props.cell,
|
|
11
11
|
row = props.row,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useMemo } from
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
import { groupConfigToGroupMap } from "../util";
|
|
3
|
-
import { jsx as _jsx } from "
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
var DefaultRow = function DefaultRow(_ref) {
|
|
5
5
|
var _groupMap$get, _groupMap$get2;
|
|
6
6
|
var rowClassName = _ref.rowClassName,
|
|
@@ -4,11 +4,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
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
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
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
|
-
import { memo } from
|
|
7
|
+
import { memo } from 'react';
|
|
8
8
|
import Cell from "./Cell";
|
|
9
|
-
import { jsx as _jsx } from "
|
|
10
|
-
import { Fragment as _Fragment } from "
|
|
11
|
-
export var DefaultRowMapper = memo(function (_ref) {
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
export var DefaultRowMapper = /*#__PURE__*/memo(function (_ref) {
|
|
12
12
|
var rowData = _ref.rowData,
|
|
13
13
|
row = _ref.row,
|
|
14
14
|
fixedInfo = _ref.fixedInfo,
|
package/dist/core/sheet/Event.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MenuRenderProps } from "../../type/sheet";
|
|
2
|
-
import React from
|
|
2
|
+
import React from 'react';
|
|
3
3
|
export declare const Menu: React.ForwardRefExoticComponent<MenuRenderProps & {
|
|
4
4
|
contextMenu?: React.FC<MenuRenderProps> | undefined;
|
|
5
5
|
showMenu: boolean;
|
package/dist/core/sheet/Menu.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { forwardRef } from
|
|
2
|
-
import { jsx as _jsx } from "
|
|
3
|
-
export var Menu = forwardRef(function (props, ref) {
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export var Menu = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
4
4
|
var showMenu = props.showMenu,
|
|
5
5
|
position = props.position,
|
|
6
6
|
cell = props.cell,
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
var rightOverflow = document.body.clientWidth - position.left < 400;
|
|
9
|
+
var bottomOverflow = document.body.clientHeight - position.top < 400;
|
|
10
|
+
if (rightOverflow && bottomOverflow) {
|
|
11
|
+
return "translate(-100%, -100%)";
|
|
12
|
+
} else if (rightOverflow && !bottomOverflow) {
|
|
13
|
+
return "translate(-100%, 40px)";
|
|
14
|
+
} else if (!rightOverflow && bottomOverflow) {
|
|
15
|
+
return "translate(0, calc(40px - 100%))";
|
|
16
|
+
}
|
|
17
|
+
return '';
|
|
18
|
+
}, [position.left, showRemark]);
|
|
19
|
+
return /*#__PURE__*/_jsx("div", {
|
|
20
|
+
ref: ref,
|
|
21
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
22
|
+
className: "harvest-remark-container ".concat(showRemark ? 'remark-show' : null),
|
|
23
|
+
style: {
|
|
24
|
+
position: 'fixed',
|
|
25
|
+
top: position.top,
|
|
26
|
+
left: position.left,
|
|
27
|
+
transform: transform
|
|
28
|
+
},
|
|
29
|
+
children: showRemark ? children : null
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
});
|
package/dist/core/sheet/index.js
CHANGED
|
@@ -4,7 +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(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
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from
|
|
7
|
+
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
8
8
|
// import ReduxLogger from 'redux-logger';
|
|
9
9
|
import ReduxThunk from 'redux-thunk';
|
|
10
10
|
import DefaultRow from "./DefaultRow";
|
|
@@ -18,18 +18,20 @@ 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";
|
|
30
|
-
import { jsx as _jsx } from "
|
|
31
|
-
import { jsxs as _jsxs } from "
|
|
32
|
-
import { Fragment as _Fragment } from "
|
|
32
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
33
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
34
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
33
35
|
var Sheet = function Sheet(props) {
|
|
34
36
|
var _visibleData$length, _scroll$y, _scroll$x;
|
|
35
37
|
var _props$sheetInstance = props.sheetInstance,
|
|
@@ -49,6 +51,7 @@ var Sheet = function Sheet(props) {
|
|
|
49
51
|
virtualized = _props$virtualized === void 0 ? false : _props$virtualized,
|
|
50
52
|
className = props.className,
|
|
51
53
|
data = props.data,
|
|
54
|
+
freeze = props.freeze,
|
|
52
55
|
_props$freePaste = props.freePaste,
|
|
53
56
|
freePaste = _props$freePaste === void 0 ? false : _props$freePaste,
|
|
54
57
|
onCellsChanged = props.onCellsChanged,
|
|
@@ -56,6 +59,7 @@ var Sheet = function Sheet(props) {
|
|
|
56
59
|
rowClassName = props.rowClassName,
|
|
57
60
|
scroll = props.scroll,
|
|
58
61
|
children = props.children,
|
|
62
|
+
ControlContainer = props.ControlContainer,
|
|
59
63
|
_props$showBackEdit = props.showBackEdit,
|
|
60
64
|
showBackEdit = _props$showBackEdit === void 0 ? true : _props$showBackEdit,
|
|
61
65
|
backEditStyle = props.backEditStyle,
|
|
@@ -65,7 +69,9 @@ var Sheet = function Sheet(props) {
|
|
|
65
69
|
hideColBar = _props$hideColBar === void 0 ? true : _props$hideColBar,
|
|
66
70
|
_props$showQuickLocat = props.showQuickLocationBtn,
|
|
67
71
|
showQuickLocationBtn = _props$showQuickLocat === void 0 ? false : _props$showQuickLocat,
|
|
68
|
-
|
|
72
|
+
_props$showRemark = props.showRemark,
|
|
73
|
+
showRemark = _props$showRemark === void 0 ? false : _props$showRemark,
|
|
74
|
+
remarkElement = props.remarkElement;
|
|
69
75
|
var _useState = useState(false),
|
|
70
76
|
_useState2 = _slicedToArray(_useState, 2),
|
|
71
77
|
isScrolledOver = _useState2[0],
|
|
@@ -126,10 +132,17 @@ var Sheet = function Sheet(props) {
|
|
|
126
132
|
},
|
|
127
133
|
goTo: function goTo(row, col) {
|
|
128
134
|
dispatch(function (d, getState) {
|
|
129
|
-
var
|
|
135
|
+
var _groupConfig$groupOpe, _groupConfig$groups;
|
|
130
136
|
var _getState2 = getState(),
|
|
131
137
|
groupConfig = _getState2.groupConfig,
|
|
132
|
-
data = _getState2.data
|
|
138
|
+
data = _getState2.data,
|
|
139
|
+
eventBus = _getState2.eventBus;
|
|
140
|
+
var nextLoop = groupConfig === null || groupConfig === void 0 || (_groupConfig$groupOpe = groupConfig.groupOpen) === null || _groupConfig$groupOpe === void 0 ? void 0 : _groupConfig$groupOpe.some(function (v) {
|
|
141
|
+
return !v;
|
|
142
|
+
});
|
|
143
|
+
if (nextLoop && groupConfig !== null && groupConfig !== void 0 && (_groupConfig$groups = groupConfig.groups) !== null && _groupConfig$groups !== void 0 && _groupConfig$groups.length) {
|
|
144
|
+
eventBus === null || eventBus === void 0 || eventBus.emit('group-open-title', true);
|
|
145
|
+
}
|
|
133
146
|
var container = sheetWrapperRef.current;
|
|
134
147
|
if (isNil(row) || isNil(col)) return;
|
|
135
148
|
var actual = rowToActualRow(row, groupConfig, data.length);
|
|
@@ -137,7 +150,15 @@ var Sheet = function Sheet(props) {
|
|
|
137
150
|
var firstRowCell = container.querySelector("td.cell[data-col='".concat(col, "']"));
|
|
138
151
|
var colPosition = firstRowCell ? firstRowCell.offsetLeft - firstRowCell.clientWidth : 0;
|
|
139
152
|
var scrollHeight = actual * rowHeight;
|
|
140
|
-
(
|
|
153
|
+
if (nextLoop) {
|
|
154
|
+
setTimeout(function () {
|
|
155
|
+
var _sheetWrapperRef$curr4;
|
|
156
|
+
(_sheetWrapperRef$curr4 = sheetWrapperRef.current) === null || _sheetWrapperRef$curr4 === void 0 || _sheetWrapperRef$curr4.scrollTo(colPosition, scrollHeight);
|
|
157
|
+
}, 1);
|
|
158
|
+
} else {
|
|
159
|
+
var _sheetWrapperRef$curr5;
|
|
160
|
+
(_sheetWrapperRef$curr5 = sheetWrapperRef.current) === null || _sheetWrapperRef$curr5 === void 0 || _sheetWrapperRef$curr5.scrollTo(colPosition, scrollHeight);
|
|
161
|
+
}
|
|
141
162
|
});
|
|
142
163
|
},
|
|
143
164
|
pushToHistory: function pushToHistory(config) {
|
|
@@ -191,30 +212,33 @@ var Sheet = function Sheet(props) {
|
|
|
191
212
|
cellChangeHandler: onCellsChanged,
|
|
192
213
|
data: data,
|
|
193
214
|
freePaste: freePaste,
|
|
194
|
-
groupConfig: groupConfig
|
|
215
|
+
groupConfig: groupConfig,
|
|
216
|
+
freeze: freeze
|
|
195
217
|
}
|
|
196
218
|
});
|
|
197
|
-
}, [onCellsChanged, data, freePaste, groupConfig]);
|
|
219
|
+
}, [onCellsChanged, data, freePaste, groupConfig, freeze]);
|
|
198
220
|
useCellEvent(dispatch, state);
|
|
199
221
|
useMouseEvent(dispatch, sheetWrapperRef);
|
|
200
222
|
useKeyBoardEvent(dispatch, sheetWrapperRef);
|
|
201
223
|
var menu = useContextMenu(dispatch, sheetWrapperRef, !!ContextMenu, contextMenuRef);
|
|
224
|
+
var _useRemarkContainer = useRemarkContainer(sheetWrapperRef, state.start, state.editing, showRemark),
|
|
225
|
+
remarkInfo = _useRemarkContainer.remarkInfo;
|
|
202
226
|
|
|
203
227
|
// timeout 的副作用不适合放reducer里面
|
|
204
228
|
useEffect(function () {
|
|
205
229
|
if (!state.editing && state.start) {
|
|
206
230
|
setTimeout(function () {
|
|
207
|
-
var _sheetWrapperRef$
|
|
231
|
+
var _sheetWrapperRef$curr6;
|
|
208
232
|
// 表格获取焦点 + 接收keyboard event
|
|
209
|
-
(_sheetWrapperRef$
|
|
233
|
+
(_sheetWrapperRef$curr6 = sheetWrapperRef.current) === null || _sheetWrapperRef$curr6 === void 0 || _sheetWrapperRef$curr6.focus({
|
|
210
234
|
preventScroll: true
|
|
211
235
|
});
|
|
212
236
|
}, 1);
|
|
213
237
|
}
|
|
214
238
|
}, [state.editing, state.start]);
|
|
215
239
|
var visibleData = useMemo(function () {
|
|
216
|
-
var _groupConfig$
|
|
217
|
-
if (!(groupConfig !== null && groupConfig !== void 0 && (_groupConfig$
|
|
240
|
+
var _groupConfig$groups2, _state$data;
|
|
241
|
+
if (!(groupConfig !== null && groupConfig !== void 0 && (_groupConfig$groups2 = groupConfig.groups) !== null && _groupConfig$groups2 !== void 0 && _groupConfig$groups2.length)) {
|
|
218
242
|
return state.data;
|
|
219
243
|
}
|
|
220
244
|
return (_state$data = state.data) === null || _state$data === void 0 ? void 0 : _state$data.filter(function (item, index) {
|
|
@@ -235,6 +259,13 @@ var Sheet = function Sheet(props) {
|
|
|
235
259
|
changeSearch = _useSearchInput.changeSearch,
|
|
236
260
|
goNext = _useSearchInput.goNext,
|
|
237
261
|
goLast = _useSearchInput.goLast;
|
|
262
|
+
useEffect(function () {
|
|
263
|
+
if (!state.mouseDown && state.start && state.end && state.start.row === state.end.row && state.start.col === state.end.col) {
|
|
264
|
+
eventBus.emit('cell-select-single', state.start);
|
|
265
|
+
} else {
|
|
266
|
+
eventBus.emit('cell-select-single', null);
|
|
267
|
+
}
|
|
268
|
+
}, [state.start, state.end, state.mouseDown]);
|
|
238
269
|
useEffect(function () {
|
|
239
270
|
dispatch({
|
|
240
271
|
type: 'clearEdit'
|
|
@@ -386,6 +417,13 @@ var Sheet = function Sheet(props) {
|
|
|
386
417
|
}
|
|
387
418
|
}), children]
|
|
388
419
|
})]
|
|
420
|
+
}), /*#__PURE__*/_jsx(Remark, {
|
|
421
|
+
showRemark: remarkInfo.show && !menu.showMenu,
|
|
422
|
+
position: {
|
|
423
|
+
left: remarkInfo.position.left,
|
|
424
|
+
top: remarkInfo.position.top
|
|
425
|
+
},
|
|
426
|
+
children: remarkElement
|
|
389
427
|
}), /*#__PURE__*/_jsx(SearchInput, {
|
|
390
428
|
style: props.searchStyle,
|
|
391
429
|
value: state.searchText,
|
|
@@ -96,6 +96,7 @@ span.harvest-sheet-container:focus {
|
|
|
96
96
|
border-right: 1px solid;
|
|
97
97
|
border-color: var(--cell-border-color);
|
|
98
98
|
content: '';
|
|
99
|
+
pointer-events: none;
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
&.cell-title {
|
|
@@ -378,3 +379,36 @@ span.harvest-sheet-container:focus {
|
|
|
378
379
|
color: #a4a9b2;
|
|
379
380
|
}
|
|
380
381
|
}
|
|
382
|
+
.harvest-remark-container{
|
|
383
|
+
border:1px solid #E5E5E5;
|
|
384
|
+
max-height: 400px;
|
|
385
|
+
border-radius: 2px;
|
|
386
|
+
z-index: 10;
|
|
387
|
+
margin-left: 5px;
|
|
388
|
+
overflow: auto;
|
|
389
|
+
padding: 0;
|
|
390
|
+
background: rgb(255,255,255);
|
|
391
|
+
box-shadow: 0 4px 8px rgba(216,223,235,.5);
|
|
392
|
+
}
|
|
393
|
+
.harvest-remark-container::-webkit-scrollbar{
|
|
394
|
+
display: none;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
.harvest-remark-container.remark-show{
|
|
398
|
+
padding: 8px;
|
|
399
|
+
animation: scaleAnimation .3s ease-in-out normal;
|
|
400
|
+
min-width:20px
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
@keyframes scaleAnimation {
|
|
404
|
+
0% {
|
|
405
|
+
scale:0;
|
|
406
|
+
opacity: 0;
|
|
407
|
+
transform-origin:top left;
|
|
408
|
+
}
|
|
409
|
+
100% {
|
|
410
|
+
scale:1;
|
|
411
|
+
opacity: 1;
|
|
412
|
+
transform-origin:top left;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CloseOutlined, DownOutlined, UpOutlined } from '@ant-design/icons';
|
|
2
2
|
import { Divider, Input } from 'antd';
|
|
3
|
-
import { useEffect, useRef } from
|
|
4
|
-
import { jsxs as _jsxs } from "
|
|
5
|
-
import { jsx as _jsx } from "
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
export var SearchInput = function SearchInput(props) {
|
|
7
7
|
var inputRef = useRef(null);
|
|
8
8
|
var _props$current = props.current,
|
|
@@ -11,7 +11,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
11
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
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
13
|
import { useSetState } from "../..";
|
|
14
|
-
import { useEffect } from
|
|
14
|
+
import { useEffect } from 'react';
|
|
15
15
|
import { calcMenuPosition, extractDataRowAndCol, findParentTd } from "../util";
|
|
16
16
|
export var useContextMenu = function useContextMenu(dispatch, elementRef) {
|
|
17
17
|
var enableContextMenu = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -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({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMouse } from "../..";
|
|
2
|
-
import { useCallback, useEffect, useRef } from
|
|
2
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
3
3
|
import { extractDataRowAndCol, findParentTd } from "../util";
|
|
4
4
|
var rowCount = 10; //每秒10行
|
|
5
5
|
var colCount = 5; //每秒5列
|
|
@@ -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
|
+
};
|