@zhenliang/sheet 0.1.22 → 0.1.24

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.
Files changed (200) hide show
  1. package/dist/core/config.d.ts +13 -0
  2. package/dist/core/config.d.ts.map +1 -0
  3. package/dist/core/config.js +13 -0
  4. package/dist/core/editor/cascaderEditor/index.d.ts +5 -0
  5. package/dist/core/editor/cascaderEditor/index.d.ts.map +1 -0
  6. package/dist/core/editor/cascaderEditor/index.js +53 -0
  7. package/dist/core/editor/cascaderEditor/index.less +32 -0
  8. package/dist/core/editor/dateEditor/index.d.ts +5 -0
  9. package/dist/core/editor/dateEditor/index.d.ts.map +1 -0
  10. package/dist/core/editor/dateEditor/index.js +56 -0
  11. package/dist/core/editor/dateEditor/index.less +18 -0
  12. package/dist/core/editor/index.d.ts +4 -0
  13. package/dist/core/editor/index.d.ts.map +1 -0
  14. package/dist/core/editor/index.js +4 -0
  15. package/dist/core/editor/numberEditor/index.d.ts +8 -0
  16. package/dist/core/editor/numberEditor/index.d.ts.map +1 -0
  17. package/dist/core/editor/numberEditor/index.js +107 -0
  18. package/dist/core/editor/numberEditor/index.less +30 -0
  19. package/dist/core/editor/selectEditor/index.d.ts +6 -0
  20. package/dist/core/editor/selectEditor/index.d.ts.map +1 -0
  21. package/dist/core/editor/selectEditor/index.js +96 -0
  22. package/dist/core/editor/selectEditor/index.less +48 -0
  23. package/dist/core/reducers/index.d.ts +9 -0
  24. package/dist/core/reducers/index.d.ts.map +1 -0
  25. package/dist/core/reducers/index.js +38 -0
  26. package/dist/core/reducers/keyboardReducer.d.ts +2 -0
  27. package/dist/core/reducers/keyboardReducer.d.ts.map +1 -0
  28. package/dist/core/reducers/keyboardReducer.js +93 -0
  29. package/dist/core/reducers/mouseReducer.d.ts +2 -0
  30. package/dist/core/reducers/mouseReducer.d.ts.map +1 -0
  31. package/dist/core/reducers/mouseReducer.js +164 -0
  32. package/dist/core/reducers/sideEffectReducer.d.ts +4 -0
  33. package/dist/core/reducers/sideEffectReducer.d.ts.map +1 -0
  34. package/dist/core/reducers/sideEffectReducer.js +378 -0
  35. package/dist/core/reducers/stateReducer.d.ts +2 -0
  36. package/dist/core/reducers/stateReducer.d.ts.map +1 -0
  37. package/dist/core/reducers/stateReducer.js +174 -0
  38. package/dist/core/sheet/Cell.d.ts +4 -0
  39. package/dist/core/sheet/Cell.d.ts.map +1 -0
  40. package/dist/core/sheet/Cell.js +181 -0
  41. package/dist/core/sheet/DataEditor.d.ts +3 -0
  42. package/dist/core/sheet/DataEditor.d.ts.map +1 -0
  43. package/dist/core/sheet/DataEditor.js +24 -0
  44. package/dist/core/sheet/DefaultCell.d.ts +12 -0
  45. package/dist/core/sheet/DefaultCell.d.ts.map +1 -0
  46. package/dist/core/sheet/DefaultCell.js +31 -0
  47. package/dist/core/sheet/DefaultRow.d.ts +12 -0
  48. package/dist/core/sheet/DefaultRow.d.ts.map +1 -0
  49. package/dist/core/sheet/DefaultRow.js +28 -0
  50. package/dist/core/sheet/DefaultRowMapper.d.ts +8 -0
  51. package/dist/core/sheet/DefaultRowMapper.d.ts.map +1 -0
  52. package/dist/core/sheet/DefaultRowMapper.js +18 -0
  53. package/dist/core/sheet/DefaultShell.d.ts +8 -0
  54. package/dist/core/sheet/DefaultShell.d.ts.map +1 -0
  55. package/dist/core/sheet/DefaultShell.js +12 -0
  56. package/dist/core/sheet/Event.d.ts +5 -0
  57. package/dist/core/sheet/Event.d.ts.map +1 -0
  58. package/dist/core/sheet/Event.js +17 -0
  59. package/dist/core/sheet/ValueViewer.d.ts +3 -0
  60. package/dist/core/sheet/ValueViewer.d.ts.map +1 -0
  61. package/dist/core/sheet/ValueViewer.js +9 -0
  62. package/dist/core/sheet/index.d.ts +5 -0
  63. package/dist/core/sheet/index.d.ts.map +1 -0
  64. package/dist/core/sheet/index.js +262 -0
  65. package/dist/core/sheet/index.less +307 -0
  66. package/dist/core/sheet/useCellEvent.d.ts +3 -0
  67. package/dist/core/sheet/useCellEvent.d.ts.map +1 -0
  68. package/dist/core/sheet/useCellEvent.js +22 -0
  69. package/dist/core/sheet/useContextMenu.d.ts +21 -0
  70. package/dist/core/sheet/useContextMenu.d.ts.map +1 -0
  71. package/dist/core/sheet/useContextMenu.js +86 -0
  72. package/dist/core/sheet/useKeyBoardEvent.d.ts +3 -0
  73. package/dist/core/sheet/useKeyBoardEvent.d.ts.map +1 -0
  74. package/dist/core/sheet/useKeyBoardEvent.js +66 -0
  75. package/dist/core/sheet/useMouseEvent.d.ts +3 -0
  76. package/dist/core/sheet/useMouseEvent.d.ts.map +1 -0
  77. package/dist/core/sheet/useMouseEvent.js +298 -0
  78. package/dist/core/sheet/useSelectVisible.d.ts +2 -0
  79. package/dist/core/sheet/useSelectVisible.d.ts.map +1 -0
  80. package/dist/core/sheet/useSelectVisible.js +57 -0
  81. package/dist/core/sheet/useVirtualList.d.ts +7 -0
  82. package/dist/core/sheet/useVirtualList.d.ts.map +1 -0
  83. package/dist/core/sheet/useVirtualList.js +103 -0
  84. package/dist/core/sheet/var.less +41 -0
  85. package/dist/core/shell/draggableShell/index.d.ts +6 -0
  86. package/dist/core/shell/draggableShell/index.d.ts.map +1 -0
  87. package/dist/core/shell/draggableShell/index.js +197 -0
  88. package/dist/core/shell/draggableShell/index.less +16 -0
  89. package/dist/core/shell/tableShell.d.ts +6 -0
  90. package/dist/core/shell/tableShell.d.ts.map +1 -0
  91. package/dist/core/shell/tableShell.js +109 -0
  92. package/dist/core/table/events.d.ts +15 -0
  93. package/dist/core/table/events.d.ts.map +1 -0
  94. package/dist/core/table/events.js +95 -0
  95. package/dist/core/table/index.d.ts +4 -0
  96. package/dist/core/table/index.d.ts.map +1 -0
  97. package/dist/core/table/index.js +313 -0
  98. package/dist/core/table/useGroupConfig.d.ts +2 -0
  99. package/dist/core/table/useGroupConfig.d.ts.map +1 -0
  100. package/dist/core/table/useGroupConfig.js +65 -0
  101. package/dist/core/table/useRowSelection.d.ts +2 -0
  102. package/dist/core/table/useRowSelection.d.ts.map +1 -0
  103. package/dist/core/table/useRowSelection.js +24 -0
  104. package/dist/core/table/util.d.ts +8 -0
  105. package/dist/core/table/util.d.ts.map +1 -0
  106. package/dist/core/table/util.js +29 -0
  107. package/dist/core/util.d.ts +58 -0
  108. package/dist/core/util.d.ts.map +1 -0
  109. package/dist/core/util.js +457 -0
  110. package/dist/core/viewer/btnViewer/index.d.ts +2 -0
  111. package/dist/core/viewer/btnViewer/index.d.ts.map +1 -0
  112. package/dist/core/viewer/btnViewer/index.js +37 -0
  113. package/dist/core/viewer/cascaderViewer/index.d.ts +2 -0
  114. package/dist/core/viewer/cascaderViewer/index.d.ts.map +1 -0
  115. package/dist/core/viewer/cascaderViewer/index.js +16 -0
  116. package/dist/core/viewer/checkViewer/index.d.ts +2 -0
  117. package/dist/core/viewer/checkViewer/index.d.ts.map +1 -0
  118. package/dist/core/viewer/checkViewer/index.js +23 -0
  119. package/dist/core/viewer/editViewer/index.d.ts +2 -0
  120. package/dist/core/viewer/editViewer/index.d.ts.map +1 -0
  121. package/dist/core/viewer/editViewer/index.js +32 -0
  122. package/dist/core/viewer/groupViewer/index.d.ts +2 -0
  123. package/dist/core/viewer/groupViewer/index.d.ts.map +1 -0
  124. package/dist/core/viewer/groupViewer/index.js +38 -0
  125. package/dist/core/viewer/index.d.ts +7 -0
  126. package/dist/core/viewer/index.d.ts.map +1 -0
  127. package/dist/core/viewer/index.js +7 -0
  128. package/dist/core/viewer/selectorViewer/index.d.ts +2 -0
  129. package/dist/core/viewer/selectorViewer/index.d.ts.map +1 -0
  130. package/dist/core/viewer/selectorViewer/index.js +16 -0
  131. package/dist/core/viewer/switchViewer/index.d.ts +2 -0
  132. package/dist/core/viewer/switchViewer/index.d.ts.map +1 -0
  133. package/dist/core/viewer/switchViewer/index.js +22 -0
  134. package/dist/example/antComponent.d.ts +3 -0
  135. package/dist/example/antComponent.d.ts.map +1 -0
  136. package/dist/example/antComponent.js +313 -0
  137. package/dist/example/basic.d.ts +4 -0
  138. package/dist/example/basic.d.ts.map +1 -0
  139. package/dist/example/basic.js +121 -0
  140. package/dist/example/ellipsis.d.ts +3 -0
  141. package/dist/example/ellipsis.d.ts.map +1 -0
  142. package/dist/example/ellipsis.js +64 -0
  143. package/dist/example/fixed.d.ts +3 -0
  144. package/dist/example/fixed.d.ts.map +1 -0
  145. package/dist/example/fixed.js +89 -0
  146. package/dist/example/group.d.ts +3 -0
  147. package/dist/example/group.d.ts.map +1 -0
  148. package/dist/example/group.js +123 -0
  149. package/dist/example/index.less +5 -0
  150. package/dist/example/selection.d.ts +4 -0
  151. package/dist/example/selection.d.ts.map +1 -0
  152. package/dist/example/selection.js +86 -0
  153. package/dist/example/sheet.d.ts +4 -0
  154. package/dist/example/sheet.d.ts.map +1 -0
  155. package/dist/example/sheet.js +397 -0
  156. package/dist/example/valuationAnalyze.d.ts +3 -0
  157. package/dist/example/valuationAnalyze.d.ts.map +1 -0
  158. package/dist/example/valuationAnalyze.js +227 -0
  159. package/dist/hooks/index.d.ts +8 -0
  160. package/dist/hooks/index.d.ts.map +1 -0
  161. package/dist/hooks/index.js +7 -0
  162. package/dist/hooks/useEventBus.d.ts +4 -0
  163. package/dist/hooks/useEventBus.d.ts.map +1 -0
  164. package/dist/hooks/useEventBus.js +17 -0
  165. package/dist/hooks/useKeyboard.d.ts +18 -0
  166. package/dist/hooks/useKeyboard.d.ts.map +1 -0
  167. package/dist/hooks/useKeyboard.js +108 -0
  168. package/dist/hooks/useMiddlewareReducer.d.ts +12 -0
  169. package/dist/hooks/useMiddlewareReducer.d.ts.map +1 -0
  170. package/dist/hooks/useMiddlewareReducer.js +47 -0
  171. package/dist/hooks/useMouse.d.ts +11 -0
  172. package/dist/hooks/useMouse.d.ts.map +1 -0
  173. package/dist/hooks/useMouse.js +68 -0
  174. package/dist/hooks/useSetState.d.ts +2 -0
  175. package/dist/hooks/useSetState.d.ts.map +1 -0
  176. package/dist/hooks/useSetState.js +27 -0
  177. package/dist/hooks/useSheetEvent.d.ts +5 -0
  178. package/dist/hooks/useSheetEvent.d.ts.map +1 -0
  179. package/dist/hooks/useSheetEvent.js +5 -0
  180. package/dist/hooks/useWidthConfig.d.ts +4 -0
  181. package/dist/hooks/useWidthConfig.d.ts.map +1 -0
  182. package/dist/hooks/useWidthConfig.js +5 -0
  183. package/dist/index.d.ts +8 -0
  184. package/dist/index.d.ts.map +1 -0
  185. package/dist/index.js +8 -0
  186. package/dist/standardUtils/index.d.ts +9 -0
  187. package/dist/standardUtils/index.d.ts.map +1 -0
  188. package/dist/standardUtils/index.js +32 -0
  189. package/dist/type/index.d.ts +2 -0
  190. package/dist/type/index.d.ts.map +1 -0
  191. package/dist/type/index.js +4 -0
  192. package/dist/type/sheet.d.ts +205 -0
  193. package/dist/type/sheet.d.ts.map +1 -0
  194. package/dist/type/sheet.js +9 -0
  195. package/dist/type/sheetTable.d.ts +89 -0
  196. package/dist/type/sheetTable.d.ts.map +1 -0
  197. package/dist/type/sheetTable.js +1 -0
  198. package/dist/typings/index.d.ts +1 -0
  199. package/package.json +1 -1
  200. package/changes.md +0 -45
@@ -0,0 +1,262 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
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
+ 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
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { useEffect, useMemo, useRef } from 'react';
8
+ // import ReduxLogger from 'redux-logger';
9
+ import ReduxThunk from 'redux-thunk';
10
+ import DefaultRow from "./DefaultRow";
11
+ import DefaultShell from "./DefaultShell";
12
+ import { ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons';
13
+ import { isNil, isNumber } from 'lodash';
14
+ import { SheetEventContext, useEventBus, useMiddlewareReducer } from "../../hooks";
15
+ import sheetReducer from "../reducers";
16
+ import { classNames, getRowHeight, rowToActualRow } from "../util";
17
+ import { DefaultRowMapper } from "./DefaultRowMapper";
18
+ import "./index.less";
19
+ import { useCellEvent } from "./useCellEvent";
20
+ import { useContextMenu } from "./useContextMenu";
21
+ import { useKeyBoardEvent } from "./useKeyBoardEvent";
22
+ import { useMouseEvent } from "./useMouseEvent";
23
+ import { useSelectVisible } from "./useSelectVisible";
24
+ import { useVirtualList } from "./useVirtualList";
25
+ import { jsx as _jsx } from "react/jsx-runtime";
26
+ import { jsxs as _jsxs } from "react/jsx-runtime";
27
+ var Sheet = function Sheet(props) {
28
+ var _state$data$length, _state$data3, _scroll$y, _scroll$x;
29
+ var _props$sheetInstance = props.sheetInstance,
30
+ sheetInstance = _props$sheetInstance === void 0 ? {
31
+ current: null
32
+ } : _props$sheetInstance,
33
+ _props$sheetRenderer = props.sheetRenderer,
34
+ SheetShell = _props$sheetRenderer === void 0 ? DefaultShell : _props$sheetRenderer,
35
+ _props$rowRenderer = props.rowRenderer,
36
+ Row = _props$rowRenderer === void 0 ? DefaultRow : _props$rowRenderer,
37
+ ContextMenu = props.menuRenderer,
38
+ _props$virtualized = props.virtualized,
39
+ virtualized = _props$virtualized === void 0 ? false : _props$virtualized,
40
+ className = props.className,
41
+ data = props.data,
42
+ _props$freePaste = props.freePaste,
43
+ freePaste = _props$freePaste === void 0 ? false : _props$freePaste,
44
+ _props$groupConfig = props.groupConfig,
45
+ groupConfig = _props$groupConfig === void 0 ? undefined : _props$groupConfig,
46
+ onCellsChanged = props.onCellsChanged,
47
+ onContextMenu = props.onContextMenu,
48
+ rowClassName = props.rowClassName,
49
+ scroll = props.scroll,
50
+ children = props.children,
51
+ showBackEdit = props.showBackEdit,
52
+ backEditStyle = props.backEditStyle;
53
+ var sheetWrapperRef = useRef(null);
54
+ var contextMenuRef = useRef(null);
55
+ var eventBus = useEventBus();
56
+ var _useMiddlewareReducer = useMiddlewareReducer(sheetReducer, {
57
+ data: data,
58
+ mouseDown: false,
59
+ editing: undefined,
60
+ lastFocus: [],
61
+ groupConfig: groupConfig,
62
+ eventBus: eventBus
63
+ },
64
+ // [ReduxThunk, ReduxLogger],
65
+ [ReduxThunk]),
66
+ _useMiddlewareReducer2 = _slicedToArray(_useMiddlewareReducer, 2),
67
+ state = _useMiddlewareReducer2[0],
68
+ dispatch = _useMiddlewareReducer2[1];
69
+ useEffect(function () {
70
+ sheetInstance.current = {
71
+ zoomTo: function zoomTo(row) {
72
+ // 给定 row 回到行
73
+ // 不给定 row 默认回到编辑行和列
74
+ dispatch(function (d, getState) {
75
+ var _ref, _sheetWrapperRef$curr;
76
+ var _getState = getState(),
77
+ start = _getState.start,
78
+ groupConfig = _getState.groupConfig,
79
+ data = _getState.data;
80
+ var container = sheetWrapperRef.current;
81
+ if (!start && isNil(row)) return;
82
+ var actual = rowToActualRow((_ref = row) !== null && _ref !== void 0 ? _ref : start === null || start === void 0 ? void 0 : start.row, groupConfig);
83
+ var rowHeight = getRowHeight(container);
84
+ var firstRowCell = container.querySelector("td.cell[data-col='".concat(start === null || start === void 0 ? void 0 : start.col, "']"));
85
+ var colPosition = firstRowCell ? firstRowCell.offsetLeft - firstRowCell.clientWidth : 0;
86
+ var scrollHeight = actual * rowHeight;
87
+ (_sheetWrapperRef$curr = sheetWrapperRef.current) === null || _sheetWrapperRef$curr === void 0 || _sheetWrapperRef$curr.scrollTo(isNumber(row) ? 0 : colPosition, scrollHeight);
88
+
89
+ // 最后一行的bug暂时用 scroll end 事件来处理
90
+ if (isNil(row) && start.row === data.length - 1 && sheetWrapperRef.current) {
91
+ var handleScrollEnd = function handleScrollEnd() {
92
+ var _sheetWrapperRef$curr2, _sheetWrapperRef$curr3;
93
+ (_sheetWrapperRef$curr2 = sheetWrapperRef.current) === null || _sheetWrapperRef$curr2 === void 0 || _sheetWrapperRef$curr2.scrollTo(isNumber(row) ? 0 : colPosition, scrollHeight);
94
+ (_sheetWrapperRef$curr3 = sheetWrapperRef.current) === null || _sheetWrapperRef$curr3 === void 0 || _sheetWrapperRef$curr3.removeEventListener('scrollend', handleScrollEnd);
95
+ };
96
+ sheetWrapperRef.current.addEventListener('scrollend', handleScrollEnd);
97
+ }
98
+ });
99
+ },
100
+ pushToHistory: function pushToHistory(config) {
101
+ dispatch({
102
+ type: 'pushHistory',
103
+ payload: config
104
+ });
105
+ },
106
+ selectRow: function selectRow(row) {
107
+ if (isNil(row)) {
108
+ dispatch({
109
+ type: 'clearSelect'
110
+ });
111
+ } else {
112
+ dispatch({
113
+ type: 'selectRow',
114
+ payload: row
115
+ });
116
+ }
117
+ },
118
+ select: function select(props) {
119
+ dispatch({
120
+ type: 'select',
121
+ payload: props
122
+ });
123
+ },
124
+ popHistory: function popHistory() {
125
+ var history = state.history;
126
+ dispatch({
127
+ type: 'popHistory'
128
+ });
129
+ return history !== null && history !== void 0 && history.length ? history === null || history === void 0 ? void 0 : history[history.length - 1] : {};
130
+ }
131
+ };
132
+ }, [sheetWrapperRef.current, state.history]);
133
+ useEffect(function () {
134
+ // 同步必要的状态
135
+ dispatch({
136
+ type: 'changes',
137
+ payload: {
138
+ cellChangeHandler: onCellsChanged,
139
+ data: data,
140
+ freePaste: freePaste,
141
+ groupConfig: groupConfig
142
+ }
143
+ });
144
+ }, [onCellsChanged, data, freePaste, groupConfig]);
145
+ useCellEvent(dispatch, state);
146
+ useMouseEvent(dispatch, sheetWrapperRef);
147
+ useKeyBoardEvent(dispatch, sheetWrapperRef);
148
+ var menu = useContextMenu(dispatch, sheetWrapperRef, !!ContextMenu, contextMenuRef);
149
+
150
+ // timeout 的副作用不适合放reducer里面
151
+ useEffect(function () {
152
+ if (!state.editing && state.start) {
153
+ setTimeout(function () {
154
+ var _sheetWrapperRef$curr4;
155
+ // 表格获取焦点 + 接收keyboard event
156
+ (_sheetWrapperRef$curr4 = sheetWrapperRef.current) === null || _sheetWrapperRef$curr4 === void 0 || _sheetWrapperRef$curr4.focus({
157
+ preventScroll: true
158
+ });
159
+ }, 1);
160
+ }
161
+ }, [state.editing, state.start]);
162
+ var _useVirtualList = useVirtualList(sheetWrapperRef, state.data, groupConfig, virtualized),
163
+ virtualStart = _useVirtualList.virtualStart,
164
+ virtualEnd = _useVirtualList.virtualEnd,
165
+ paddingTop = _useVirtualList.paddingTop,
166
+ paddingBottom = _useVirtualList.paddingBottom;
167
+ useEffect(function () {
168
+ dispatch({
169
+ type: 'clearEdit'
170
+ });
171
+ dispatch({
172
+ type: 'clearSelectIfNotSingleRow'
173
+ });
174
+ }, [groupConfig]);
175
+ var rowElements = useMemo(function () {
176
+ var _state$data;
177
+ return state === null || state === void 0 || (_state$data = state.data) === null || _state$data === void 0 || (_state$data = _state$data.slice(virtualStart, virtualEnd)) === null || _state$data === void 0 ? void 0 : _state$data.map(function (rowData) {
178
+ var _state$data2, _rowData;
179
+ var row = (state === null || state === void 0 || (_state$data2 = state.data) === null || _state$data2 === void 0 ? void 0 : _state$data2.indexOf(rowData)) || 0;
180
+ var rowCN = rowClassName instanceof Function ? rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(rowData === null || rowData === void 0 || (_rowData = rowData[rowData.length - 1]) === null || _rowData === void 0 ? void 0 : _rowData.record, row) : rowClassName;
181
+ return /*#__PURE__*/_jsx(Row, {
182
+ row: row,
183
+ cells: rowData,
184
+ groupConfig: groupConfig,
185
+ rowClassName: rowCN,
186
+ children: /*#__PURE__*/_jsx(DefaultRowMapper, {
187
+ rowData: rowData,
188
+ row: row
189
+ })
190
+ }, row);
191
+ });
192
+ }, [state.data, groupConfig, virtualStart, virtualEnd, rowClassName]);
193
+ var memoHeight = Math.min(((_state$data$length = state === null || state === void 0 || (_state$data3 = state.data) === null || _state$data3 === void 0 ? void 0 : _state$data3.length) !== null && _state$data$length !== void 0 ? _state$data$length : 0) + 1, 10) * 42 + 43;
194
+ var _useSelectVisible = useSelectVisible(sheetWrapperRef, state.start),
195
+ _useSelectVisible2 = _slicedToArray(_useSelectVisible, 2),
196
+ startRowVisible = _useSelectVisible2[0],
197
+ direction = _useSelectVisible2[1];
198
+ return /*#__PURE__*/_jsx(SheetEventContext.Provider, {
199
+ value: eventBus,
200
+ children: /*#__PURE__*/_jsxs("span", {
201
+ children: [/*#__PURE__*/_jsxs("span", {
202
+ ref: sheetWrapperRef,
203
+ tabIndex: 0,
204
+ className: classNames('harvest harvest-sheet-container', className),
205
+ style: {
206
+ maxHeight: (_scroll$y = scroll === null || scroll === void 0 ? void 0 : scroll.y) !== null && _scroll$y !== void 0 ? _scroll$y : memoHeight,
207
+ width: (_scroll$x = scroll === null || scroll === void 0 ? void 0 : scroll.x) !== null && _scroll$x !== void 0 ? _scroll$x : '100%'
208
+ },
209
+ children: [/*#__PURE__*/_jsxs(SheetShell, {
210
+ className: classNames('harvest-sheet', className),
211
+ children: [virtualized && paddingTop > 0 && /*#__PURE__*/_jsx("tr", {
212
+ style: {
213
+ height: 0,
214
+ paddingBottom: paddingTop,
215
+ display: 'block'
216
+ }
217
+ }), rowElements, virtualized && paddingBottom > 0 && /*#__PURE__*/_jsx("tr", {
218
+ style: {
219
+ height: 0,
220
+ paddingBottom: paddingBottom,
221
+ display: 'block'
222
+ }
223
+ })]
224
+ }, "sheet"), ContextMenu ? /*#__PURE__*/_jsx("div", {
225
+ ref: contextMenuRef,
226
+ style: {
227
+ display: menu.showMenu ? '' : 'none'
228
+ },
229
+ children: /*#__PURE__*/_jsx(ContextMenu, {
230
+ position: menu.position,
231
+ cell: menu.cellPosition,
232
+ onContextMenu: onContextMenu
233
+ })
234
+ }) : null]
235
+ }), /*#__PURE__*/_jsxs("div", {
236
+ className: "harvest-sheet-control",
237
+ children: [children, showBackEdit && !startRowVisible ? /*#__PURE__*/_jsxs("div", {
238
+ className: "back-edit",
239
+ onClick: function onClick() {
240
+ var _sheetInstance$curren;
241
+ return sheetInstance === null || sheetInstance === void 0 || (_sheetInstance$curren = sheetInstance.current) === null || _sheetInstance$curren === void 0 ? void 0 : _sheetInstance$curren.zoomTo();
242
+ },
243
+ style: !backEditStyle ? {
244
+ top: 0,
245
+ right: 0
246
+ } : backEditStyle,
247
+ children: [direction === 'up' ? /*#__PURE__*/_jsx(ArrowUpOutlined, {
248
+ rev: undefined
249
+ }) : /*#__PURE__*/_jsx(ArrowDownOutlined, {
250
+ rev: undefined
251
+ }), /*#__PURE__*/_jsx("span", {
252
+ style: {
253
+ marginLeft: 0
254
+ },
255
+ children: "\u8FD4\u56DE\u7F16\u8F91\u884C"
256
+ })]
257
+ }) : null]
258
+ })]
259
+ })
260
+ });
261
+ };
262
+ export default Sheet;
@@ -0,0 +1,307 @@
1
+ @import './var.less';
2
+
3
+ .harvest-sheet-container{
4
+ overflow: auto;
5
+ display: block;
6
+ position: relative ;
7
+ // scroll-behavior:smooth;
8
+ }
9
+
10
+ .harvest-sheet-container .header{
11
+ z-index: 2;
12
+
13
+ }
14
+
15
+
16
+
17
+
18
+ span.harvest-sheet-container, span.harvest-sheet-container:focus {
19
+ outline: none;
20
+ }
21
+
22
+ .harvest-sheet-container .harvest-sheet {
23
+ width: 100%;
24
+ border-collapse: collapse;
25
+ table-layout: fixed;
26
+
27
+ tr{
28
+ height:var(--row-height);
29
+
30
+ th.cell-title{
31
+ line-height: var(--row-height);
32
+ border-bottom: 1px solid transparent;
33
+ }
34
+
35
+ td{
36
+ line-height: var(--row-height);
37
+ }
38
+
39
+ &:last-of-type{
40
+ .td{
41
+ border-bottom: 1px solid transparent;
42
+ }
43
+
44
+ }
45
+ }
46
+
47
+ }
48
+
49
+ .harvest-sheet-container .harvest-sheet .cell {
50
+ height: 17px;
51
+ font-size: var(--cell-font-size);
52
+ padding-left:var(--cell-padding-horizontal);
53
+ padding-right:var(--cell-padding-horizontal);
54
+ padding-top:var(--cell-padding-vertical);
55
+ padding-bottom:var(--cell-padding-vertical);
56
+ border: 1px solid var(--cell-border-color);
57
+ background-color: var(--cell-background-color);
58
+ cursor: cell;
59
+ text-align: right;
60
+ // transition: box-shadow 100ms ease-out;
61
+ user-select: none;
62
+ vertical-align: bottom;
63
+ position: relative;
64
+
65
+ }
66
+
67
+
68
+ .harvest-sheet-container .harvest-sheet .cell.fixed{
69
+ position: sticky;
70
+ z-index: 2;
71
+
72
+ &.cell-title{
73
+ z-index: 3;
74
+
75
+ }
76
+
77
+
78
+ &::before{
79
+ position: absolute;
80
+ top: -1px;
81
+ left: 0;
82
+ width: 100%;
83
+ border-color: var(--cell-border-color);
84
+ border-top: 1px solid var(--cell-border-color);
85
+ content: "";
86
+ }
87
+
88
+ &.fixed-left::after{
89
+ position: absolute;
90
+ top: 0;
91
+ bottom: -1px;
92
+ right: -1px;
93
+ width: 30px;
94
+ border-left: 1px solid var(--cell-border-color);
95
+ content: "";
96
+ pointer-events: none;
97
+ transform: translate(100%);
98
+ transition: box-shadow .3s;
99
+ box-shadow: var(--cell-fixed-box-shadow-left);
100
+ }
101
+
102
+
103
+ &.fixed-right{
104
+ transform: translateX(1px);
105
+ }
106
+
107
+ &.fixed-right::after{
108
+ position: absolute;
109
+ top: 0;
110
+ bottom: -1px;
111
+ left: -1px;
112
+ width: 30px;
113
+ border-right: 1px solid var(--cell-border-color);
114
+ content: "";
115
+ pointer-events: none;
116
+ transform: translate(-100%);
117
+ transition: box-shadow .3s;
118
+ box-shadow: var(--cell-fixed-box-shadow-right);
119
+
120
+
121
+ }
122
+
123
+ &.fixed-unset{
124
+ position: unset;
125
+ }
126
+ }
127
+
128
+
129
+ .harvest-sheet-container .harvest-sheet .cell.selected {
130
+ border:1px double;
131
+ border-color:var(--cell-border-color);
132
+ box-shadow: var(--cell-box-shadow);
133
+ }
134
+
135
+ .harvest-sheet-container .harvest-sheet .cell.selected-start {
136
+ box-shadow: none;
137
+ }
138
+
139
+ .harvest-sheet-container .harvest-sheet .cell.selected-top{
140
+ border-top-color: var(--resizer);
141
+ border-top-width: 1px;
142
+ }
143
+
144
+ .harvest-sheet-container .harvest-sheet .cell.selected-left{
145
+ border-left-color: var(--resizer);
146
+ border-left-width:1px;
147
+ }
148
+
149
+ .harvest-sheet-container .harvest-sheet .cell.selected-bottom{
150
+ border-bottom-color: var(--resizer);
151
+ border-bottom-width:1px;
152
+ }
153
+
154
+ .harvest-sheet-container .harvest-sheet .cell.selected-right{
155
+ border-right-color: var(--resizer);
156
+ border-right-width:1px;
157
+ }
158
+
159
+
160
+ .harvest-sheet-container .harvest-sheet .cell.sheet-control{
161
+ border-right: 1px solid transparent;
162
+ background: var(--cell-background-color) ;
163
+ color:var(--read-color);
164
+
165
+ &.read-only{
166
+ border-right: 1px solid var(--cell-title-background-color);
167
+ }
168
+ // position: relative !important;
169
+ }
170
+
171
+ .harvest-sheet-container .harvest-sheet .cell.read-only {
172
+ background: var(--cell-read-only-background-color);
173
+ color: var(--read-color);
174
+ text-align: center;
175
+ cursor: not-allowed;
176
+ }
177
+
178
+
179
+ .harvest-sheet-container .harvest-sheet .cell-title.sheet-control{
180
+ border-right: 1px solid var(--cell-title-background-color);
181
+ }
182
+
183
+ .harvest-sheet-container .harvest-sheet .cell.cell-title{
184
+ background-color: var(--cell-title-background-color);
185
+
186
+ &:hover{
187
+ background-color: var(--cell-title-background-color);
188
+
189
+ }
190
+ }
191
+
192
+
193
+ .harvest-sheet-container .harvest-sheet .cell:not(.cell.read-only):hover{
194
+ background-color: var(--cell-hover);
195
+ }
196
+
197
+
198
+
199
+ .harvest-sheet-container .harvest-sheet .cell > .text {
200
+ overflow: hidden;
201
+ padding: 2px 5px;
202
+ text-overflow: ellipsis;
203
+ }
204
+
205
+
206
+ .harvest-sheet-container .harvest-sheet .cell > input {
207
+ display: block;
208
+ width: calc(100% - 6px);
209
+ font-size: var(--cell-font-size);
210
+ height: 11px;
211
+ border: 2px solid rgb(33, 133, 208);
212
+ background: none;
213
+ outline: none !important;
214
+ text-align:inherit;
215
+ }
216
+
217
+ .harvest-sheet-container .harvest-sheet .cell,
218
+ .harvest-sheet-container .harvest-sheet.wrap .cell,
219
+ .harvest-sheet-container .harvest-sheet .cell.wrap,
220
+ .harvest-sheet-container .harvest-sheet.wrap .cell.wrap,
221
+ .harvest-sheet-container .harvest-sheet.nowrap .cell.wrap,
222
+ .harvest-sheet-container .harvest-sheet.clip .cell.wrap {
223
+ white-space: normal;
224
+ }
225
+
226
+ .harvest-sheet-container .harvest-sheet.nowrap .cell,
227
+ .harvest-sheet-container .harvest-sheet .cell.nowrap,
228
+ .harvest-sheet-container .harvest-sheet.nowrap .cell.nowrap,
229
+ .harvest-sheet-container .harvest-sheet.wrap .cell.nowrap,
230
+ .harvest-sheet-container .harvest-sheet.clip .cell.nowrap {
231
+ overflow-x: visible;
232
+ white-space: nowrap;
233
+ }
234
+
235
+ .harvest-sheet-container .harvest-sheet.clip .cell,
236
+ .harvest-sheet-container .harvest-sheet .cell.clip,
237
+ .harvest-sheet-container .harvest-sheet.clip .cell.clip,
238
+ .harvest-sheet-container .harvest-sheet.wrap .cell.clip,
239
+ .harvest-sheet-container .harvest-sheet.nowrap .cell.clip {
240
+ overflow-x: hidden;
241
+ white-space: nowrap;
242
+ }
243
+
244
+ .harvest-sheet-container .harvest-sheet .cell .value-viewer{
245
+ overflow: hidden;
246
+ text-overflow: ellipsis;
247
+ white-space: nowrap;
248
+ }
249
+
250
+ .harvest-sheet-container .harvest-sheet .cell .value-viewer, .harvest-sheet-container .harvest-sheet .cell .data-editor {
251
+ display: block;
252
+ font-size: var(--cell-font-size);
253
+ line-height:var(--cell-inner-height) ;
254
+ height:var(--cell-inner-height) ;
255
+ padding:0
256
+ }
257
+
258
+ .harvest-sheet-container .harvest-sheet .cell .data-editor {
259
+ border:none;
260
+ border-radius: none;
261
+ height:var(--cell-inner-height);
262
+ }
263
+
264
+
265
+
266
+ .harvest-sheet-container .harvest-menu{
267
+ background-color: white;
268
+ position: fixed;
269
+ z-index: 3;
270
+ box-shadow: 0 3px 12px 2px rgba(31, 35, 41, 10%);
271
+
272
+ .harvest-menu-item{
273
+ margin: 1px 3px;
274
+ padding: 4px 8px;
275
+ cursor: pointer;
276
+ font-size: 14px;
277
+ line-height: 22px;
278
+
279
+ &:hover{
280
+ background-color: rgba(31, 35, 41, 5%)
281
+ }
282
+ }
283
+
284
+ }
285
+
286
+ .harvest-sheet-control{
287
+ position: relative;
288
+ z-index: 3;
289
+ bottom: 0;
290
+ left: 0;
291
+ background-color: white;
292
+ }
293
+
294
+ .harvest-sheet-control .back-edit{
295
+ padding: 5px 8px;
296
+ margin: 1px;
297
+ height: 30px;
298
+ display: flex;
299
+ width: 105px;
300
+ cursor: pointer;
301
+ align-items: center;
302
+ justify-content: center;
303
+ position: absolute;
304
+ z-index: 4;
305
+ border:1px solid #D8DFEB;
306
+ border-radius:2px;
307
+ }
@@ -0,0 +1,3 @@
1
+ import { Dispatch } from "../../hooks/useMiddlewareReducer";
2
+ import type { SheetType } from "../../type";
3
+ export declare const useCellEvent: (dispatch: Dispatch, listenerVar?: Partial<SheetType.UpdateStateType>) => void;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCellEvent.d.ts","sourceRoot":"","sources":["useCellEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,yCAAoD;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,mBAA8B;AAIvD,eAAO,MAAM,YAAY,aACb,QAAQ,gBACJ,QAAQ,UAAU,eAAe,CAAC,SAiBjD,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { useEffect } from 'react';
2
+ import { sideEffectReducer } from "../reducers";
3
+ export var useCellEvent = function useCellEvent(dispatch, listenerVar) {
4
+ var _ref = listenerVar || {},
5
+ start = _ref.start,
6
+ end = _ref.end,
7
+ lastSelected = _ref.lastSelected,
8
+ editing = _ref.editing,
9
+ lastEditing = _ref.lastEditing;
10
+ useEffect(function () {
11
+ dispatch(sideEffectReducer.init);
12
+ return function () {
13
+ dispatch(sideEffectReducer.destroy);
14
+ };
15
+ }, []);
16
+ useEffect(function () {
17
+ dispatch(sideEffectReducer.emitSelectChange);
18
+ }, [start, end, lastSelected]);
19
+ useEffect(function () {
20
+ dispatch(sideEffectReducer.emitEditChange);
21
+ }, [editing, lastEditing]);
22
+ };
@@ -0,0 +1,21 @@
1
+ import { Dispatch } from "../..";
2
+ import type { SheetType } from "../../type";
3
+ export type MenuEvent = {
4
+ showMenu: boolean;
5
+ position: {
6
+ top: number;
7
+ left: number;
8
+ };
9
+ cellPosition: SheetType.CellPosition;
10
+ };
11
+ export declare const useContextMenu: (dispatch: Dispatch, elementRef: React.RefObject<SheetType.refAssertion>, enableContextMenu: boolean | undefined, contextMenuRef: React.RefObject<HTMLDivElement>) => {
12
+ showMenu: boolean;
13
+ position: {
14
+ top: number;
15
+ left: number;
16
+ };
17
+ cellPosition: {
18
+ row: number;
19
+ col: number;
20
+ };
21
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContextMenu.d.ts","sourceRoot":"","sources":["useContextMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAe,cAAyB;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,mBAA8B;AAIvD,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,YAAY,EAAE,SAAS,CAAC,YAAY,CAAC;CACtC,CAAC;AAEF,eAAO,MAAM,cAAc,aACf,QAAQ,cACN,MAAM,SAAS,CAAC,UAAU,YAAY,CAAC,0DAEnC,MAAM,SAAS,CAAC,cAAc,CAAC;;;;;;;;;;CA0DhD,CAAC"}