@zhenliang/sheet 0.1.7-3.beta.12 → 0.1.7-3.beta.13

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.
@@ -201,6 +201,16 @@ var Sheet = function Sheet(props) {
201
201
  }
202
202
  });
203
203
  return history !== null && history !== void 0 ? history : [];
204
+ },
205
+ call: function call(caller) {
206
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
207
+ args[_key - 1] = arguments[_key];
208
+ }
209
+ return dispatch(function (d, getState) {
210
+ var _getState3 = getState(),
211
+ data = _getState3.data;
212
+ caller === null || caller === void 0 || caller.apply(void 0, args.concat([data]));
213
+ });
204
214
  }
205
215
  };
206
216
  }, [state.history]);
@@ -188,7 +188,9 @@ export var useMouseEvent = function useMouseEvent(dispatch, elementRef) {
188
188
  });
189
189
  }, []);
190
190
  var mouseUp = useCallback(function (e) {
191
- e.preventDefault();
191
+ // input select 问题
192
+ // e.preventDefault();
193
+
192
194
  resetInterval();
193
195
  var currentCell = findParentTd(e.target);
194
196
  if (!currentCell || currentCell.classList.contains('fixed')) {
@@ -287,7 +289,7 @@ export var useMouseEvent = function useMouseEvent(dispatch, elementRef) {
287
289
  }, []);
288
290
  useEffect(function () {
289
291
  if (elementRef.current) {
290
- if (navigator.appVersion.indexOf("Mac") !== -1) {
292
+ if (navigator.appVersion.indexOf('Mac') !== -1) {
291
293
  elementRef.current.style.setProperty('--arrow-down', 'var(--arrow-mac-down)');
292
294
  elementRef.current.style.setProperty('--arrow-right', 'var(--arrow-mac-right)');
293
295
  }
@@ -62,6 +62,21 @@ export var useRemarkContainer = function useRemarkContainer(elementRef, start, e
62
62
  }, [showRemark, editing]);
63
63
  useEffect(function () {
64
64
  var _elementRef$current, _elementRef$current2;
65
+ var scrollTimer;
66
+ var remarkScrollEnd = function remarkScrollEnd() {
67
+ var position = calcPosition();
68
+ if (!position) {
69
+ return;
70
+ }
71
+ // end called
72
+ if (scrollTimer) {
73
+ clearTimeout(scrollTimer);
74
+ }
75
+ setRemarkInfo({
76
+ position: position,
77
+ show: position.visible && showRemark && !editing && position.left > 0 && position.top > 0
78
+ });
79
+ };
65
80
  var remarkScroll = throttle(function () {
66
81
  var _ref = elementRef.current || {},
67
82
  _ref$scrollTop = _ref.scrollTop,
@@ -77,17 +92,14 @@ export var useRemarkContainer = function useRemarkContainer(elementRef, start, e
77
92
  setRemarkInfo({
78
93
  show: false
79
94
  });
80
- }, 50);
81
- var remarkScrollEnd = function remarkScrollEnd() {
82
- var position = calcPosition();
83
- if (!position) {
84
- return;
95
+ if (scrollTimer) {
96
+ clearTimeout(scrollTimer);
85
97
  }
86
- setRemarkInfo({
87
- position: position,
88
- show: position.visible && showRemark && !editing && position.left > 0 && position.top > 0
89
- });
90
- };
98
+ scrollTimer = setTimeout(function () {
99
+ remarkScrollEnd();
100
+ clearTimeout(scrollTimer);
101
+ }, 100);
102
+ }, 50);
91
103
  (_elementRef$current = elementRef.current) === null || _elementRef$current === void 0 || _elementRef$current.addEventListener('scroll', remarkScroll);
92
104
  (_elementRef$current2 = elementRef.current) === null || _elementRef$current2 === void 0 || _elementRef$current2.addEventListener('scrollend', remarkScrollEnd);
93
105
  return function () {
@@ -5,10 +5,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
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; }
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
7
  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); }
8
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
- 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."); }
10
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
8
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
9
  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."); }
14
10
  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); }
@@ -21,7 +17,6 @@ import { Sheet, useSetState } from "../..";
21
17
  import { GroupContext } from "../../hooks/useGroupConfig";
22
18
  import { WidthContext } from "../../hooks/useWidthConfig";
23
19
  import { ConfigProvider, Empty } from 'antd';
24
- import { flatten } from 'lodash';
25
20
  import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
26
21
  import { SheetEvent } from "../sheet/Event";
27
22
  import { DraggableShell } from "../shell/draggableShell";
@@ -74,18 +69,15 @@ var Table = function Table(_ref) {
74
69
  useImperativeHandle(sheetRef, function () {
75
70
  return new Proxy({}, {
76
71
  get: function get(target, property) {
77
- var _sheetInstance$curren3;
78
- var flatDataSource = flatten(dataSource.map(function (item) {
79
- return item.children ? [item].concat(_toConsumableArray(item.children)) : [item];
80
- }));
72
+ var _sheetInstance$curren4;
81
73
  if (property === 'goToByTable') {
82
- return function (id, columnKey) {
83
- var _sheetInstance$curren, _sheetInstance$curren2;
84
- var toCol = columns.findIndex(function (column) {
85
- return column.dataIndex === columnKey;
86
- }) + offset;
87
- var toRow = flatDataSource.findIndex(function (d) {
88
- return String(d === null || d === void 0 ? void 0 : d.id) === String(id);
74
+ var goToByTable = function goToByTable(id, columnKey, currentData) {
75
+ var _currentData$, _sheetInstance$curren, _sheetInstance$curren2;
76
+ var toCol = currentData === null || currentData === void 0 || (_currentData$ = currentData[0]) === null || _currentData$ === void 0 ? void 0 : _currentData$.findIndex(function (d) {
77
+ return d.dataIndex === columnKey;
78
+ });
79
+ var toRow = currentData.findIndex(function (d) {
80
+ return String(d === null || d === void 0 ? void 0 : d[0].id) === String(id);
89
81
  });
90
82
  (_sheetInstance$curren = sheetInstance.current) === null || _sheetInstance$curren === void 0 || _sheetInstance$curren.goTo(toRow, toCol);
91
83
  (_sheetInstance$curren2 = sheetInstance.current) === null || _sheetInstance$curren2 === void 0 || _sheetInstance$curren2.select({
@@ -99,8 +91,15 @@ var Table = function Table(_ref) {
99
91
  }
100
92
  });
101
93
  };
94
+ return function () {
95
+ var _sheetInstance$curren3;
96
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
97
+ args[_key] = arguments[_key];
98
+ }
99
+ (_sheetInstance$curren3 = sheetInstance.current) === null || _sheetInstance$curren3 === void 0 || _sheetInstance$curren3.call.apply(_sheetInstance$curren3, [goToByTable].concat(args));
100
+ };
102
101
  }
103
- return (_sheetInstance$curren3 = sheetInstance.current) === null || _sheetInstance$curren3 === void 0 ? void 0 : _sheetInstance$curren3[property];
102
+ return (_sheetInstance$curren4 = sheetInstance.current) === null || _sheetInstance$curren4 === void 0 ? void 0 : _sheetInstance$curren4[property];
104
103
  }
105
104
  });
106
105
  }, [columns, dataSource, offset]);
@@ -106,6 +106,7 @@ export type SheetInstance = {
106
106
  }) => void;
107
107
  popHistory: () => OperateHistory;
108
108
  dropHistory: () => OperateHistory[];
109
+ call: (caller: (...args: any) => void, ...args: any) => void;
109
110
  };
110
111
  export type SheetProps = {
111
112
  sheetInstance?: React.MutableRefObject<SheetInstance | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.73.beta.12",
3
+ "version": "0.1.73.beta.13",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",