@zhenliang/sheet 0.1.7-3.beta.11 → 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.
@@ -8,9 +8,9 @@ export var Remark = /*#__PURE__*/forwardRef(function (props, ref) {
8
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
- return "translate(-100%, -100%)";
11
+ return "translate(calc(-100% - 4px), calc(-100% - 4px))";
12
12
  } else if (rightOverflow && !bottomOverflow) {
13
- return "translate(-100%, 40px)";
13
+ return "translate(calc(-100% - 4px), 44px)";
14
14
  } else if (!rightOverflow && bottomOverflow) {
15
15
  return "translate(0, calc(40px - 100%))";
16
16
  }
@@ -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]);
@@ -390,6 +390,7 @@ span.harvest-sheet-container:focus {
390
390
  padding: 0;
391
391
  background: rgb(255,255,255);
392
392
  box-shadow: 0 4px 8px rgba(216,223,235,.5);
393
+ transition: top .1s linear,left .1s linear,transform .05s linear;
393
394
  }
394
395
  .harvest-remark-container::-webkit-scrollbar{
395
396
  display: none;
@@ -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,21 +62,44 @@ 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 remarkScroll = throttle(function () {
66
- setRemarkInfo({
67
- show: false
68
- });
69
- }, 50);
65
+ var scrollTimer;
70
66
  var remarkScrollEnd = function remarkScrollEnd() {
71
67
  var position = calcPosition();
72
68
  if (!position) {
73
69
  return;
74
70
  }
71
+ // end called
72
+ if (scrollTimer) {
73
+ clearTimeout(scrollTimer);
74
+ }
75
75
  setRemarkInfo({
76
76
  position: position,
77
77
  show: position.visible && showRemark && !editing && position.left > 0 && position.top > 0
78
78
  });
79
79
  };
80
+ var remarkScroll = throttle(function () {
81
+ var _ref = elementRef.current || {},
82
+ _ref$scrollTop = _ref.scrollTop,
83
+ scrollTop = _ref$scrollTop === void 0 ? 0 : _ref$scrollTop,
84
+ _ref$scrollHeight = _ref.scrollHeight,
85
+ scrollHeight = _ref$scrollHeight === void 0 ? 0 : _ref$scrollHeight,
86
+ _ref$clientHeight = _ref.clientHeight,
87
+ clientHeight = _ref$clientHeight === void 0 ? 0 : _ref$clientHeight;
88
+ // 滚动条抖动导致的
89
+ if (Math.abs(clientHeight + scrollTop - scrollHeight) <= 1) {
90
+ return;
91
+ }
92
+ setRemarkInfo({
93
+ show: false
94
+ });
95
+ if (scrollTimer) {
96
+ clearTimeout(scrollTimer);
97
+ }
98
+ scrollTimer = setTimeout(function () {
99
+ remarkScrollEnd();
100
+ clearTimeout(scrollTimer);
101
+ }, 100);
102
+ }, 50);
80
103
  (_elementRef$current = elementRef.current) === null || _elementRef$current === void 0 || _elementRef$current.addEventListener('scroll', remarkScroll);
81
104
  (_elementRef$current2 = elementRef.current) === null || _elementRef$current2 === void 0 || _elementRef$current2.addEventListener('scrollend', remarkScrollEnd);
82
105
  return function () {
@@ -96,13 +119,13 @@ export var useRemarkContainer = function useRemarkContainer(elementRef, start, e
96
119
  }
97
120
  var io = new IntersectionObserver(function (entries) {
98
121
  var ratio = entries[0].intersectionRatio;
99
- if (ratio < 0.8) {
122
+ if (ratio < 0.5) {
100
123
  setRemarkInfo({
101
124
  show: false
102
125
  });
103
126
  }
104
127
  }, {
105
- threshold: 0.8
128
+ threshold: 0.5
106
129
  });
107
130
  io.observe(cell);
108
131
  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]);
@@ -240,7 +239,6 @@ var Table = function Table(_ref) {
240
239
  columnKey: columnKey,
241
240
  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
242
241
  });
243
- console.log(data);
244
242
  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)));
245
243
  }, [offset, columns, data]);
246
244
  var remarkElement = useMemo(function () {
@@ -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.11",
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",