@zhenliang/sheet 0.1.19 → 0.1.22

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 (137) hide show
  1. package/changes.md +45 -0
  2. package/package.json +1 -1
  3. package/dist/core/config.d.ts +0 -13
  4. package/dist/core/config.js +0 -13
  5. package/dist/core/editor/cascaderEditor/index.d.ts +0 -5
  6. package/dist/core/editor/cascaderEditor/index.js +0 -54
  7. package/dist/core/editor/cascaderEditor/index.less +0 -28
  8. package/dist/core/editor/dateEditor/index.d.ts +0 -5
  9. package/dist/core/editor/dateEditor/index.js +0 -55
  10. package/dist/core/editor/dateEditor/index.less +0 -11
  11. package/dist/core/editor/index.d.ts +0 -4
  12. package/dist/core/editor/index.js +0 -4
  13. package/dist/core/editor/numberEditor/index.d.ts +0 -8
  14. package/dist/core/editor/numberEditor/index.js +0 -107
  15. package/dist/core/editor/numberEditor/index.less +0 -30
  16. package/dist/core/editor/selectEditor/index.d.ts +0 -6
  17. package/dist/core/editor/selectEditor/index.js +0 -96
  18. package/dist/core/editor/selectEditor/index.less +0 -43
  19. package/dist/core/reducers/index.d.ts +0 -9
  20. package/dist/core/reducers/index.js +0 -38
  21. package/dist/core/reducers/keyboardReducer.d.ts +0 -2
  22. package/dist/core/reducers/keyboardReducer.js +0 -93
  23. package/dist/core/reducers/mouseReducer.d.ts +0 -2
  24. package/dist/core/reducers/mouseReducer.js +0 -164
  25. package/dist/core/reducers/sideEffectReducer.d.ts +0 -4
  26. package/dist/core/reducers/sideEffectReducer.js +0 -376
  27. package/dist/core/reducers/stateReducer.d.ts +0 -2
  28. package/dist/core/reducers/stateReducer.js +0 -174
  29. package/dist/core/sheet/Cell.d.ts +0 -4
  30. package/dist/core/sheet/Cell.js +0 -181
  31. package/dist/core/sheet/DataEditor.d.ts +0 -3
  32. package/dist/core/sheet/DataEditor.js +0 -24
  33. package/dist/core/sheet/DefaultCell.d.ts +0 -11
  34. package/dist/core/sheet/DefaultCell.js +0 -31
  35. package/dist/core/sheet/DefaultRow.d.ts +0 -12
  36. package/dist/core/sheet/DefaultRow.js +0 -28
  37. package/dist/core/sheet/DefaultRowMapper.d.ts +0 -8
  38. package/dist/core/sheet/DefaultRowMapper.js +0 -15
  39. package/dist/core/sheet/DefaultShell.d.ts +0 -8
  40. package/dist/core/sheet/DefaultShell.js +0 -12
  41. package/dist/core/sheet/Event.d.ts +0 -5
  42. package/dist/core/sheet/Event.js +0 -17
  43. package/dist/core/sheet/ValueViewer.d.ts +0 -3
  44. package/dist/core/sheet/ValueViewer.js +0 -9
  45. package/dist/core/sheet/index.d.ts +0 -5
  46. package/dist/core/sheet/index.js +0 -265
  47. package/dist/core/sheet/index.less +0 -307
  48. package/dist/core/sheet/useCellEvent.d.ts +0 -3
  49. package/dist/core/sheet/useCellEvent.js +0 -22
  50. package/dist/core/sheet/useContextMenu.d.ts +0 -21
  51. package/dist/core/sheet/useContextMenu.js +0 -86
  52. package/dist/core/sheet/useKeyBoardEvent.d.ts +0 -3
  53. package/dist/core/sheet/useKeyBoardEvent.js +0 -66
  54. package/dist/core/sheet/useMouseEvent.d.ts +0 -3
  55. package/dist/core/sheet/useMouseEvent.js +0 -298
  56. package/dist/core/sheet/useSelectVisible.d.ts +0 -2
  57. package/dist/core/sheet/useSelectVisible.js +0 -57
  58. package/dist/core/sheet/useVirtualList.d.ts +0 -7
  59. package/dist/core/sheet/useVirtualList.js +0 -103
  60. package/dist/core/sheet/var.less +0 -41
  61. package/dist/core/shell/draggableShell/index.d.ts +0 -5
  62. package/dist/core/shell/draggableShell/index.js +0 -197
  63. package/dist/core/shell/draggableShell/index.less +0 -16
  64. package/dist/core/shell/tableShell.d.ts +0 -5
  65. package/dist/core/shell/tableShell.js +0 -109
  66. package/dist/core/table/events.d.ts +0 -15
  67. package/dist/core/table/events.js +0 -95
  68. package/dist/core/table/index.d.ts +0 -4
  69. package/dist/core/table/index.js +0 -313
  70. package/dist/core/table/useGroupConfig.d.ts +0 -2
  71. package/dist/core/table/useGroupConfig.js +0 -65
  72. package/dist/core/table/useRowSelection.d.ts +0 -2
  73. package/dist/core/table/useRowSelection.js +0 -24
  74. package/dist/core/table/util.d.ts +0 -8
  75. package/dist/core/table/util.js +0 -29
  76. package/dist/core/util.d.ts +0 -59
  77. package/dist/core/util.js +0 -490
  78. package/dist/core/viewer/btnViewer/index.d.ts +0 -2
  79. package/dist/core/viewer/btnViewer/index.js +0 -37
  80. package/dist/core/viewer/cascaderViewer/index.d.ts +0 -2
  81. package/dist/core/viewer/cascaderViewer/index.js +0 -11
  82. package/dist/core/viewer/checkViewer/index.d.ts +0 -2
  83. package/dist/core/viewer/checkViewer/index.js +0 -23
  84. package/dist/core/viewer/editViewer/index.d.ts +0 -2
  85. package/dist/core/viewer/editViewer/index.js +0 -31
  86. package/dist/core/viewer/groupViewer/index.d.ts +0 -2
  87. package/dist/core/viewer/groupViewer/index.js +0 -34
  88. package/dist/core/viewer/index.d.ts +0 -7
  89. package/dist/core/viewer/index.js +0 -7
  90. package/dist/core/viewer/selectorViewer/index.d.ts +0 -2
  91. package/dist/core/viewer/selectorViewer/index.js +0 -16
  92. package/dist/core/viewer/switchViewer/index.d.ts +0 -2
  93. package/dist/core/viewer/switchViewer/index.js +0 -22
  94. package/dist/example/antComponent.d.ts +0 -3
  95. package/dist/example/antComponent.js +0 -314
  96. package/dist/example/basic.d.ts +0 -4
  97. package/dist/example/basic.js +0 -121
  98. package/dist/example/ellipsis.d.ts +0 -3
  99. package/dist/example/ellipsis.js +0 -64
  100. package/dist/example/fixed.d.ts +0 -3
  101. package/dist/example/fixed.js +0 -89
  102. package/dist/example/group.d.ts +0 -3
  103. package/dist/example/group.js +0 -123
  104. package/dist/example/index.less +0 -5
  105. package/dist/example/selection.d.ts +0 -4
  106. package/dist/example/selection.js +0 -86
  107. package/dist/example/sheet.d.ts +0 -4
  108. package/dist/example/sheet.js +0 -393
  109. package/dist/example/valuationAnalyze.d.ts +0 -2
  110. package/dist/example/valuationAnalyze.js +0 -227
  111. package/dist/hooks/index.d.ts +0 -8
  112. package/dist/hooks/index.js +0 -7
  113. package/dist/hooks/useEventBus.d.ts +0 -3
  114. package/dist/hooks/useEventBus.js +0 -17
  115. package/dist/hooks/useKeyboard.d.ts +0 -18
  116. package/dist/hooks/useKeyboard.js +0 -108
  117. package/dist/hooks/useMiddlewareReducer.d.ts +0 -12
  118. package/dist/hooks/useMiddlewareReducer.js +0 -47
  119. package/dist/hooks/useMouse.d.ts +0 -11
  120. package/dist/hooks/useMouse.js +0 -68
  121. package/dist/hooks/useSetState.d.ts +0 -2
  122. package/dist/hooks/useSetState.js +0 -27
  123. package/dist/hooks/useSheetEvent.d.ts +0 -5
  124. package/dist/hooks/useSheetEvent.js +0 -5
  125. package/dist/hooks/useWidthConfig.d.ts +0 -4
  126. package/dist/hooks/useWidthConfig.js +0 -5
  127. package/dist/index.d.ts +0 -8
  128. package/dist/index.js +0 -8
  129. package/dist/standardUtils/index.d.ts +0 -9
  130. package/dist/standardUtils/index.js +0 -32
  131. package/dist/type/index.d.ts +0 -2
  132. package/dist/type/index.js +0 -4
  133. package/dist/type/sheet.d.ts +0 -205
  134. package/dist/type/sheet.js +0 -9
  135. package/dist/type/sheetTable.d.ts +0 -89
  136. package/dist/type/sheetTable.js +0 -1
  137. package/dist/typings/index.d.ts +0 -1
@@ -1,227 +0,0 @@
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(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import { getNumberEditor, getSelectEditor, Table } from "./..";
8
- import { Button } from 'antd';
9
- import { isNil } from 'lodash';
10
- import { useCallback, useState } from 'react';
11
- import { SwitchViewer } from "../core/viewer";
12
- import { SheetType } from "../type";
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- var RateValueInput = getNumberEditor({
15
- addonAfter: '%',
16
- min: 0,
17
- max: 100
18
- });
19
- var ValueInput = getNumberEditor({
20
- min: 0,
21
- max: 100000000
22
- });
23
- var RateViewer = function RateViewer(props) {
24
- var value = props.value;
25
- return /*#__PURE__*/_jsx("span", {
26
- children: value ? value + '%' : '-'
27
- });
28
- };
29
- var data = [{
30
- id: 2443,
31
- draftId: '101601',
32
- valuationType: 2,
33
- termDiscountRate: null,
34
- reversionDiscountRate: null,
35
- vacancyDiscountRate: null,
36
- discountRate: 8.5,
37
- exitCapRate: 4.5,
38
- gfaUnitPrice: 107350.31545913525,
39
- nlaUnitPrice: 90130.38038659678,
40
- totalValuation: 1622707368.4802885,
41
- isEnabled: true
42
- }, {
43
- id: 2444,
44
- draftId: '101601',
45
- valuationType: 5,
46
- termDiscountRate: 4.5,
47
- reversionDiscountRate: 5.5,
48
- vacancyDiscountRate: 5.5,
49
- discountRate: null,
50
- exitCapRate: null,
51
- gfaUnitPrice: 89327.04427210477,
52
- nlaUnitPrice: 89327.04427210477,
53
- totalValuation: 1429232708.3536763,
54
- isEnabled: false
55
- }];
56
- var evaluateMethods = [{
57
- label: 'DCF',
58
- value: 2
59
- }, {
60
- label: 'T&R',
61
- value: 5
62
- }];
63
- var EvaSelect = getSelectEditor(evaluateMethods);
64
- export default (function () {
65
- var _useState = useState(data),
66
- _useState2 = _slicedToArray(_useState, 1),
67
- state = _useState2[0];
68
- var columns = [{
69
- title: '默认使用',
70
- dataIndex: 'isEnabled',
71
- width: 66,
72
- // cellType: 'operate',
73
- readonly: function readonly(value, record) {
74
- return !!record.valuationType;
75
- },
76
- render: SwitchViewer
77
- // component: (record: any, row: number, col: number) => (
78
- // <Switch
79
- // disabled={isNil(record.valuationType)}
80
- // checked={record.isEnabled}
81
- // onChange={handleSwitchChange(record, row)}
82
- // />
83
- // ),
84
- }, {
85
- title: '评估方法',
86
- dataIndex: 'valuationType',
87
- width: 134,
88
- readonly: function readonly(value, record, row) {
89
- return !row;
90
- },
91
- render: function (props) {
92
- var _evaluateMethods$find;
93
- return /*#__PURE__*/_jsx("span", {
94
- children: (_evaluateMethods$find = evaluateMethods.find(function (item) {
95
- return item.value === props.value;
96
- })) === null || _evaluateMethods$find === void 0 ? void 0 : _evaluateMethods$find.label
97
- });
98
- },
99
- editor: getSelectEditor(evaluateMethods)
100
- // calcReadOnly: (record, rowIndex) => !rowIndex,
101
- // getSelectOptions: (record: any) => {
102
- // if (record.valuationType === 2) {
103
- // return evaluateMethods.slice(0, 1);
104
- // }
105
- // return evaluateMethods.slice(1);
106
- // },
107
- }, {
108
- title: '租期内折现率',
109
- dataIndex: 'termDiscountRate',
110
- width: 134,
111
- editor: RateValueInput,
112
- render: RateViewer,
113
- readonly: function readonly(value, record, row) {
114
- return !row || isNil(record.valuationType);
115
- }
116
- // calcReadOnly: (record, rowIndex) => !rowIndex || isNil(record.valuationType),
117
- }, {
118
- title: '租期外折现率',
119
- dataIndex: 'reversionDiscountRate',
120
- width: 134,
121
- render: RateViewer,
122
- editor: RateValueInput,
123
- readonly: function readonly(value, record, row) {
124
- return !row || isNil(record.valuationType);
125
- }
126
- }, {
127
- title: '空置面积折现率',
128
- dataIndex: 'vacancyDiscountRate',
129
- width: 134,
130
- render: RateViewer,
131
- editor: RateValueInput,
132
- readonly: function readonly(value, record, row) {
133
- return !row || isNil(record.valuationType);
134
- }
135
- }, {
136
- title: '折现率',
137
- dataIndex: 'discountRate',
138
- width: 134,
139
- render: RateViewer,
140
- editor: EvaSelect,
141
- readonly: function readonly(value, record, row) {
142
- return !row || isNil(record.valuationType);
143
- }
144
- }, {
145
- title: '退出资本化率',
146
- dataIndex: 'exitCapRate',
147
- width: 134,
148
- render: RateViewer,
149
- editor: RateValueInput,
150
- readonly: function readonly(value, record, row) {
151
- return !row || isNil(record.valuationType);
152
- }
153
- }, {
154
- title: '估值单价/GFA',
155
- dataIndex: 'gfaUnitPrice',
156
- width: 134,
157
- editor: ValueInput,
158
- readonly: true
159
- }, {
160
- title: '估值单价/NLA',
161
- dataIndex: 'nlaUnitPrice',
162
- width: 134,
163
- editor: ValueInput,
164
- readonly: true
165
- }, {
166
- title: '估值',
167
- dataIndex: 'totalValuation',
168
- width: 134,
169
- editor: ValueInput,
170
- readonly: true
171
- }, {
172
- title: '操作',
173
- width: 62,
174
- dataIndex: 'id',
175
- fixed: SheetType.CellAlign.right,
176
- editable: false,
177
- render: function (props) {
178
- var row = props.row,
179
- record = props.record;
180
- if (row) {
181
- return /*#__PURE__*/_jsx("div", {
182
- children: /*#__PURE__*/_jsx(Button, {
183
- type: "link",
184
- onClick: function onClick() {
185
- // handleDelete((record as { id: number }).id);
186
- // const infos = [{ id: record.id, row, extra: record }];
187
- // operateCb && operateCb(4, { row, infos });
188
- },
189
- size: "small",
190
- children: "\u5220\u9664"
191
- })
192
- });
193
- }
194
- return /*#__PURE__*/_jsx("div", {
195
- className: "value-viewer number-value-viewer"
196
- });
197
- }
198
-
199
- // component: (record: any, row: number, col: number, operateCb?: ExcelTableType.OperateCollector) => {
200
- // if (row) {
201
- // return (
202
- // <div>
203
- // <Button
204
- // type="link"
205
- // onClick={() => {
206
- // handleDelete(record.id);
207
- // const infos = [{ id: record.id, row, extra: record }];
208
- // operateCb && operateCb(4, { row, infos });
209
- // }}
210
- // size="small"
211
- // >
212
- // 删除
213
- // </Button>
214
- // </div>
215
- // );
216
- // }
217
- // return <div className="value-viewer number-value-viewer" />;
218
- // },
219
- }];
220
-
221
- var handleChange = useCallback(function () {}, [state]);
222
- return /*#__PURE__*/_jsx(Table, {
223
- columns: columns,
224
- dataSource: state,
225
- onChange: handleChange
226
- });
227
- });
@@ -1,8 +0,0 @@
1
- export { useEventBus } from './useEventBus';
2
- export { useKeyBoard } from './useKeyboard';
3
- export { useMiddlewareReducer } from './useMiddlewareReducer';
4
- export type { Dispatch, FunctionAction, NormalAction, } from './useMiddlewareReducer';
5
- export { useMouse } from './useMouse';
6
- export { useSetState } from './useSetState';
7
- export { SheetEventContext, useSheetEvent } from './useSheetEvent';
8
- export { useWidth, WidthContext } from './useWidthConfig';
@@ -1,7 +0,0 @@
1
- export { useEventBus } from "./useEventBus";
2
- export { useKeyBoard } from "./useKeyboard";
3
- export { useMiddlewareReducer } from "./useMiddlewareReducer";
4
- export { useMouse } from "./useMouse";
5
- export { useSetState } from "./useSetState";
6
- export { SheetEventContext, useSheetEvent } from "./useSheetEvent";
7
- export { useWidth, WidthContext } from "./useWidthConfig";
@@ -1,3 +0,0 @@
1
- import EventEmitter from 'events';
2
- declare const useEventBus: () => EventEmitter;
3
- export { useEventBus };
@@ -1,17 +0,0 @@
1
- import EventEmitter from 'events';
2
- import { useEffect, useRef } from 'react';
3
- var useEventBus = function useEventBus() {
4
- var eventBus = useRef(new EventEmitter());
5
- useEffect(function () {
6
- return function () {
7
- var _eventBus$current;
8
- (_eventBus$current = eventBus.current) === null || _eventBus$current === void 0 ? void 0 : _eventBus$current.removeAllListeners();
9
- eventBus.current = null;
10
- };
11
- }, []);
12
- if (!eventBus.current) {
13
- eventBus.current = new EventEmitter();
14
- }
15
- return eventBus.current;
16
- };
17
- export { useEventBus };
@@ -1,18 +0,0 @@
1
- declare type KeyOrClipBoardEvent = (event: KeyboardEvent | ClipboardEvent, value?: any) => void;
2
- declare type KeyboardHandler = {
3
- move: KeyOrClipBoardEvent;
4
- escape: KeyOrClipBoardEvent;
5
- delete: KeyOrClipBoardEvent;
6
- enter: KeyOrClipBoardEvent;
7
- otherInput: KeyOrClipBoardEvent;
8
- copy: KeyOrClipBoardEvent;
9
- paste: KeyOrClipBoardEvent;
10
- reverse: KeyOrClipBoardEvent;
11
- cut: KeyOrClipBoardEvent;
12
- };
13
- export declare function move(keyCode: number, isShiftKey: boolean): {
14
- row: number;
15
- col: number;
16
- } | undefined;
17
- export declare const useKeyBoard: (handler: KeyboardHandler, listenElement: HTMLSpanElement | null) => void;
18
- export {};
@@ -1,108 +0,0 @@
1
- import { useCallback, useEffect } from 'react';
2
- import { BACKSPACE_KEY, C_KEY, DELETE_KEY, DOWN_KEY, ENTER_KEY, ESCAPE_KEY, LEFT_KEY, RIGHT_KEY, TAB_KEY, UP_KEY, V_KEY, X_KEY, Z_KEY } from "../core/config";
3
- import { isInputKey } from "../core/util";
4
- var ua = window.navigator.userAgent;
5
- var isIE = /MSIE|Trident/.test(ua);
6
- export function move(keyCode, isShiftKey) {
7
- if (keyCode === TAB_KEY) {
8
- return {
9
- row: 0,
10
- col: isShiftKey ? -1 : 1
11
- };
12
- } else if (keyCode === RIGHT_KEY) {
13
- return {
14
- row: 0,
15
- col: 1
16
- };
17
- } else if (keyCode === LEFT_KEY) {
18
- return {
19
- row: 0,
20
- col: -1
21
- };
22
- } else if (keyCode === UP_KEY) {
23
- return {
24
- row: -1,
25
- col: 0
26
- };
27
- } else if (keyCode === DOWN_KEY) {
28
- return {
29
- row: 1,
30
- col: 0
31
- };
32
- } else if (keyCode === ENTER_KEY) {
33
- return {
34
- row: isShiftKey ? -1 : 1,
35
- col: 0
36
- };
37
- }
38
- }
39
- export var useKeyBoard = function useKeyBoard(handler, listenElement) {
40
- var handleKey = useCallback(function (e) {
41
- if (e.defaultPrevented) {
42
- return;
43
- }
44
- var ctrlKey = e.ctrlKey,
45
- metaKey = e.metaKey,
46
- keyCode = e.keyCode,
47
- shiftKey = e.shiftKey;
48
- var ctrlKeyPressed = ctrlKey || metaKey;
49
- var isEscape = keyCode === ESCAPE_KEY;
50
- if (isEscape) {
51
- handler.escape(e);
52
- return;
53
- }
54
- var isReverse = ctrlKeyPressed && keyCode === Z_KEY;
55
- if (isReverse) {
56
- handler.reverse(e);
57
- return;
58
- }
59
- var isCopy = ctrlKeyPressed && keyCode === C_KEY;
60
- if (isCopy && isIE) {
61
- handler.copy(e);
62
- return;
63
- }
64
- var isCut = ctrlKeyPressed && keyCode === X_KEY;
65
- if (isCut && isIE) {
66
- handler.copy(e);
67
- return;
68
- }
69
- var isPaste = ctrlKeyPressed && keyCode === V_KEY;
70
- if (isPaste && isIE) {
71
- handler.paste(e);
72
- return;
73
- }
74
- var isDelete = keyCode === DELETE_KEY || keyCode === BACKSPACE_KEY;
75
- if (isDelete) {
76
- handler.delete(e);
77
- return;
78
- }
79
- var isEnter = keyCode === ENTER_KEY;
80
- if (isEnter && !shiftKey) {
81
- handler.enter(e);
82
- return;
83
- }
84
- if (ctrlKeyPressed) {
85
- return;
86
- }
87
- var isValueInput = isInputKey(keyCode);
88
- if (isValueInput) {
89
- handler.otherInput(e, e.key);
90
- return false;
91
- }
92
- var moveInfo = move(keyCode, shiftKey);
93
- moveInfo && handler.move(e, moveInfo);
94
- }, [handler]);
95
- useEffect(function () {
96
- if (!listenElement) return;
97
- listenElement.addEventListener('keydown', handleKey);
98
- document.addEventListener('copy', handler.copy);
99
- document.addEventListener('paste', handler.paste);
100
- document.addEventListener('cut', handler.cut);
101
- return function () {
102
- listenElement.removeEventListener('keydown', handleKey);
103
- document.removeEventListener('copy', handler.copy);
104
- document.removeEventListener('paste', handler.paste);
105
- document.removeEventListener('cut', handler.cut);
106
- };
107
- }, [listenElement]);
108
- };
@@ -1,12 +0,0 @@
1
- export declare type NormalAction = {
2
- type: string;
3
- payload?: any;
4
- };
5
- export declare type FunctionAction = (dispatch: any, getState?: () => any) => any;
6
- export declare type Dispatch = (action: any) => any;
7
- export declare type MiddlewareAPI<A> = {
8
- getState: () => A;
9
- dispatch: Dispatch;
10
- };
11
- export declare type Middleware<A> = (api: MiddlewareAPI<A>) => (next: Dispatch) => Dispatch;
12
- export declare const useMiddlewareReducer: <A, B>(reducer: (state: A, action: B) => A, initialState: A, middleware?: Middleware<A>[]) => [A, Dispatch];
@@ -1,47 +0,0 @@
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(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- import * as React from 'react';
8
- export var useMiddlewareReducer = function useMiddlewareReducer(reducer, initialState) {
9
- var middleware = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
10
- var _React$useState = React.useState(initialState),
11
- _React$useState2 = _slicedToArray(_React$useState, 2),
12
- state = _React$useState2[0],
13
- setState = _React$useState2[1];
14
- var stateRef = React.useRef(state);
15
- var dispatch = React.useMemo(function () {
16
- var dispatch = function dispatch() {
17
- throw new Error("Dispatching while constructing your middleware is not allowed. " + "Other middleware would not be applied to this dispatch.");
18
- };
19
- var middlewareAPI = {
20
- getState: function getState() {
21
- return stateRef.current;
22
- },
23
- dispatch: function (_dispatch) {
24
- function dispatch(_x2) {
25
- return _dispatch.apply(this, arguments);
26
- }
27
- dispatch.toString = function () {
28
- return _dispatch.toString();
29
- };
30
- return dispatch;
31
- }(function (action) {
32
- return dispatch(action);
33
- })
34
- };
35
- var localDispatch = function localDispatch(action) {
36
- stateRef.current = reducer(stateRef.current, action);
37
- setState(stateRef.current);
38
- };
39
- dispatch = middleware.map(function (middleware) {
40
- return middleware(middlewareAPI);
41
- }).reduceRight(function (acc, middleware) {
42
- return middleware(acc);
43
- }, localDispatch);
44
- return dispatch;
45
- }, []);
46
- return [state, dispatch];
47
- };
@@ -1,11 +0,0 @@
1
- declare type MouseHandler = {
2
- mouseUp: (value: MouseEvent) => void;
3
- mouseDown: (value: MouseEvent) => void;
4
- mouseOver: (value: MouseEvent) => void;
5
- mouseLeave: (value: MouseEvent) => void;
6
- mouseEnter: (value: MouseEvent) => void;
7
- doubleClick: (value: MouseEvent) => void;
8
- loseFocus: (value: MouseEvent) => void;
9
- };
10
- export declare const useMouse: (handler: MouseHandler, listenElement: HTMLSpanElement | null) => void;
11
- export {};
@@ -1,68 +0,0 @@
1
- import { debounce } from 'lodash';
2
- import { useCallback, useEffect, useRef } from 'react';
3
- export var useMouse = function useMouse(handler, listenElement) {
4
- var mouseUp = handler.mouseUp,
5
- mouseDown = handler.mouseDown,
6
- mouseOver = handler.mouseOver,
7
- mouseLeave = handler.mouseLeave,
8
- mouseEnter = handler.mouseEnter,
9
- doubleClick = handler.doubleClick,
10
- loseFocus = handler.loseFocus;
11
- var handlerRef = useRef();
12
-
13
- // todo
14
- var wrapper = useCallback(function (handle) {
15
- return function (e) {
16
- if (!listenElement.contains(e.target)) {
17
- return;
18
- }
19
- handle(e);
20
- };
21
- }, [listenElement]);
22
- useEffect(function () {
23
- return function () {
24
- if (!handlerRef.current) return;
25
- var _handlerRef$current = handlerRef.current,
26
- listenerMouseUp = _handlerRef$current.mouseUp,
27
- listenerMouseDown = _handlerRef$current.mouseDown,
28
- listenerMouseOver = _handlerRef$current.mouseOver,
29
- listenerMouseLeave = _handlerRef$current.mouseLeave,
30
- listenerMouseEnter = _handlerRef$current.mouseEnter,
31
- listenerDoubleClick = _handlerRef$current.doubleClick;
32
- document.removeEventListener('mouseup', listenerMouseUp);
33
- document.removeEventListener('mousedown', listenerMouseDown);
34
- document.removeEventListener('dblclick', listenerDoubleClick);
35
- listenElement === null || listenElement === void 0 ? void 0 : listenElement.removeEventListener('mouseover', listenerMouseOver);
36
- listenElement === null || listenElement === void 0 ? void 0 : listenElement.removeEventListener('mouseleave', listenerMouseLeave);
37
- listenElement === null || listenElement === void 0 ? void 0 : listenElement.removeEventListener('mouseenter', listenerMouseEnter);
38
- };
39
- }, []);
40
- useEffect(function () {
41
- if (!listenElement) return;
42
- var debounceOver = debounce(mouseOver, 10);
43
- var wrappedMouseUp = mouseUp;
44
- var wrappedMouseDown = function wrappedMouseDown(e) {
45
- if (!(listenElement !== null && listenElement !== void 0 && listenElement.contains(e.target))) {
46
- loseFocus(e);
47
- return;
48
- }
49
- mouseDown(e);
50
- };
51
- var wrappedMouseDoubleClick = wrapper(doubleClick);
52
- handlerRef.current = {
53
- mouseUp: wrappedMouseUp,
54
- mouseDown: wrappedMouseDown,
55
- doubleClick: wrappedMouseDoubleClick,
56
- mouseOver: debounceOver,
57
- mouseLeave: mouseLeave,
58
- mouseEnter: mouseEnter,
59
- loseFocus: loseFocus
60
- };
61
- document.addEventListener('mouseup', wrappedMouseUp);
62
- document.addEventListener('mousedown', wrappedMouseDown);
63
- document.addEventListener('dblclick', wrappedMouseDoubleClick);
64
- listenElement === null || listenElement === void 0 ? void 0 : listenElement.addEventListener('mouseover', debounceOver);
65
- listenElement === null || listenElement === void 0 ? void 0 : listenElement.addEventListener('mouseleave', mouseLeave);
66
- listenElement === null || listenElement === void 0 ? void 0 : listenElement.addEventListener('mouseenter', mouseEnter);
67
- }, [listenElement]);
68
- };
@@ -1,2 +0,0 @@
1
- declare const useSetState: <T extends object>(initialState?: T) => [T, (patch: Partial<T> | ((prevState: T) => Partial<T>)) => void];
2
- export { useSetState };
@@ -1,27 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
- 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."); }
9
- 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); }
10
- 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; }
11
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
12
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- import { useCallback, useState } from 'react';
14
- var useSetState = function useSetState() {
15
- var initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
- var _useState = useState(initialState),
17
- _useState2 = _slicedToArray(_useState, 2),
18
- state = _useState2[0],
19
- setState = _useState2[1];
20
- var setMergeState = useCallback(function (patch) {
21
- setState(function (prevState) {
22
- return _objectSpread(_objectSpread({}, prevState), typeof patch === 'function' ? patch(prevState) : patch);
23
- });
24
- }, []);
25
- return [state, setMergeState];
26
- };
27
- export { useSetState };
@@ -1,5 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="react" />
3
- import Events from 'events';
4
- export declare const SheetEventContext: import("react").Context<Events | undefined>;
5
- export declare function useSheetEvent(): Events;
@@ -1,5 +0,0 @@
1
- import { createContext, useContext } from 'react';
2
- export var SheetEventContext = /*#__PURE__*/createContext(undefined);
3
- export function useSheetEvent() {
4
- return useContext(SheetEventContext);
5
- }
@@ -1,4 +0,0 @@
1
- /// <reference types="react" />
2
- import { WidthConfig } from '../type/sheet';
3
- export declare const WidthContext: import("react").Context<WidthConfig>;
4
- export declare function useWidth(): WidthConfig;
@@ -1,5 +0,0 @@
1
- import { createContext, useContext } from 'react';
2
- export var WidthContext = /*#__PURE__*/createContext({});
3
- export function useWidth() {
4
- return useContext(WidthContext);
5
- }
package/dist/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { SheetTableType, SheetType } from './type';
2
- export * from './core/editor';
3
- export { default as Sheet } from './core/sheet';
4
- export { default as Table } from './core/table';
5
- export * from './core/viewer';
6
- export * from './hooks';
7
- export { useSheetEvent } from './hooks/useSheetEvent';
8
- export { SheetTableType, SheetType };
package/dist/index.js DELETED
@@ -1,8 +0,0 @@
1
- import { SheetTableType, SheetType } from "./type";
2
- export * from "./core/editor";
3
- export { default as Sheet } from "./core/sheet";
4
- export { default as Table } from "./core/table";
5
- export * from "./core/viewer";
6
- export * from "./hooks";
7
- export { useSheetEvent } from "./hooks/useSheetEvent";
8
- export { SheetTableType, SheetType };
@@ -1,9 +0,0 @@
1
- declare type ValueParams = string | number | null | undefined;
2
- export declare const formatPrecision: (value: ValueParams, precision?: number) => string;
3
- /**
4
- * 千位分隔符
5
- * @param value 需要千分符格式化的数据
6
- * @returns 含千分符的字符串
7
- */
8
- export declare const thousandsSeparator: (value: string | number) => string;
9
- export {};
@@ -1,32 +0,0 @@
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(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
- export var formatPrecision = function formatPrecision(value) {
8
- var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
9
- if (Number.isNaN(Number(value)) || value === null || value === 0) {
10
- return '0';
11
- }
12
- var b = Math.pow(10, precision);
13
- var res = Math.round(Number(value) * b) / b;
14
- return res.toFixed(precision);
15
- };
16
-
17
- /**
18
- * 千位分隔符
19
- * @param value 需要千分符格式化的数据
20
- * @returns 含千分符的字符串
21
- */
22
- export var thousandsSeparator = function thousandsSeparator(value) {
23
- var _String$split = String(value).split('.'),
24
- _String$split2 = _slicedToArray(_String$split, 2),
25
- integer = _String$split2[0],
26
- decimal = _String$split2[1];
27
- var formattedData = integer === null || integer === void 0 ? void 0 : integer.replace(/(\d{1,3})(?=(\d{3})+$)/g, '$1,');
28
- if (decimal && decimal.length) {
29
- formattedData += ".".concat(decimal);
30
- }
31
- return formattedData;
32
- };