@zhenliang/sheet 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/dist/core/config.js +1 -2
- package/dist/core/editor/cascaderEditor/index.js +14 -7
- package/dist/core/editor/dateEditor/index.d.ts +2 -1
- package/dist/core/editor/dateEditor/index.js +44 -36
- package/dist/core/editor/index.d.ts +1 -1
- package/dist/core/editor/index.js +2 -3
- package/dist/core/editor/numberEditor/index.d.ts +1 -1
- package/dist/core/editor/numberEditor/index.js +53 -5
- package/dist/core/editor/numberEditor/index.less +1 -0
- package/dist/core/editor/selectEditor/index.d.ts +1 -1
- package/dist/core/editor/selectEditor/index.js +34 -5
- package/dist/core/reducers/index.d.ts +1 -1
- package/dist/core/reducers/index.js +3 -2
- package/dist/core/reducers/keyboardReducer.js +2 -3
- package/dist/core/reducers/mouseReducer.js +1 -2
- package/dist/core/reducers/sideEffectReducer.js +61 -26
- package/dist/core/reducers/stateReducer.js +38 -9
- package/dist/core/sheet/Cell.js +37 -15
- package/dist/core/sheet/DataEditor.js +4 -2
- package/dist/core/sheet/DefaultCell.js +1 -2
- package/dist/core/sheet/DefaultRow.d.ts +1 -0
- package/dist/core/sheet/DefaultRow.js +5 -3
- package/dist/core/sheet/DefaultRowMapper.js +1 -2
- package/dist/core/sheet/DefaultShell.js +1 -2
- package/dist/core/sheet/Event.js +2 -3
- package/dist/core/sheet/ValueViewer.js +1 -2
- package/dist/core/sheet/index.js +60 -20
- package/dist/core/sheet/index.less +20 -11
- package/dist/core/sheet/useCellEvent.js +1 -2
- package/dist/core/sheet/useContextMenu.d.ts +1 -1
- package/dist/core/sheet/useContextMenu.js +2 -3
- package/dist/core/sheet/useKeyBoardEvent.js +15 -3
- package/dist/core/sheet/useMouseEvent.js +3 -4
- package/dist/core/sheet/useSelectVisible.d.ts +2 -0
- package/dist/core/sheet/useSelectVisible.js +48 -0
- package/dist/core/sheet/useVirtualList.d.ts +1 -1
- package/dist/core/sheet/useVirtualList.js +24 -12
- package/dist/core/shell/draggableShell/index.js +21 -13
- package/dist/core/shell/tableShell.js +9 -6
- package/dist/core/table/events.d.ts +15 -0
- package/dist/core/table/events.js +94 -0
- package/dist/core/table/index.js +91 -112
- package/dist/core/table/useGroupConfig.js +24 -7
- package/dist/core/table/useRowSelection.d.ts +2 -1
- package/dist/core/table/useRowSelection.js +1 -2
- package/dist/core/table/util.js +2 -3
- package/dist/core/util.d.ts +5 -2
- package/dist/core/util.js +97 -16
- package/dist/core/viewer/btnViewer/index.js +2 -3
- package/dist/core/viewer/cascaderViewer/index.d.ts +2 -0
- package/dist/core/viewer/cascaderViewer/index.js +11 -0
- package/dist/core/viewer/checkViewer/index.js +2 -3
- package/dist/core/viewer/editViewer/index.js +2 -3
- package/dist/core/viewer/groupViewer/index.js +5 -3
- package/dist/core/viewer/index.d.ts +1 -0
- package/dist/core/viewer/index.js +2 -2
- package/dist/core/viewer/selectorViewer/index.d.ts +2 -0
- package/dist/core/viewer/selectorViewer/index.js +12 -0
- package/dist/core/viewer/switchViewer/index.js +2 -3
- package/dist/example/antComponent.js +60 -14
- package/dist/example/basic.js +2 -3
- package/dist/example/ellipsis.js +1 -2
- package/dist/example/fixed.js +1 -2
- package/dist/example/group.js +42 -4
- package/dist/example/selection.js +2 -3
- package/dist/example/sheet.js +52 -16
- package/dist/example/valuationAnalyze.js +20 -18
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useEventBus.js +1 -2
- package/dist/hooks/useKeyboard.js +1 -2
- package/dist/hooks/useMiddlewareReducer.js +1 -2
- package/dist/hooks/useMouse.js +35 -20
- package/dist/hooks/useSetState.js +1 -2
- package/dist/hooks/useSheetEvent.js +1 -2
- package/dist/hooks/useWidthConfig.d.ts +4 -0
- package/dist/hooks/useWidthConfig.js +5 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -1
- package/dist/standardUtils/index.js +2 -3
- package/dist/type/index.js +1 -2
- package/dist/type/sheet.d.ts +14 -3
- package/dist/type/sheet.js +1 -2
- package/dist/type/sheetTable.d.ts +45 -16
- package/dist/type/sheetTable.js +1 -2
- package/package.json +1 -1
- package/dist/core/config.js.map +0 -1
- package/dist/core/editor/cascaderEditor/index.js.map +0 -1
- package/dist/core/editor/dateEditor/index.js.map +0 -1
- package/dist/core/editor/index.js.map +0 -1
- package/dist/core/editor/numberEditor/index.js.map +0 -1
- package/dist/core/editor/selectEditor/index.js.map +0 -1
- package/dist/core/reducers/index.js.map +0 -1
- package/dist/core/reducers/keyboardReducer.js.map +0 -1
- package/dist/core/reducers/mouseReducer.js.map +0 -1
- package/dist/core/reducers/sideEffectReducer.js.map +0 -1
- package/dist/core/reducers/stateReducer.js.map +0 -1
- package/dist/core/sheet/Cell.js.map +0 -1
- package/dist/core/sheet/DataEditor.js.map +0 -1
- package/dist/core/sheet/DefaultCell.js.map +0 -1
- package/dist/core/sheet/DefaultRow.js.map +0 -1
- package/dist/core/sheet/DefaultRowMapper.js.map +0 -1
- package/dist/core/sheet/DefaultShell.js.map +0 -1
- package/dist/core/sheet/Event.js.map +0 -1
- package/dist/core/sheet/ValueViewer.js.map +0 -1
- package/dist/core/sheet/index.js.map +0 -1
- package/dist/core/sheet/useCellEvent.js.map +0 -1
- package/dist/core/sheet/useContextMenu.js.map +0 -1
- package/dist/core/sheet/useKeyBoardEvent.js.map +0 -1
- package/dist/core/sheet/useMouseEvent.js.map +0 -1
- package/dist/core/sheet/useVirtualList.js.map +0 -1
- package/dist/core/shell/draggableShell/index.js.map +0 -1
- package/dist/core/shell/tableShell.js.map +0 -1
- package/dist/core/table/index.js.map +0 -1
- package/dist/core/table/useGroupConfig.js.map +0 -1
- package/dist/core/table/useRowSelection.js.map +0 -1
- package/dist/core/table/util.js.map +0 -1
- package/dist/core/util.js.map +0 -1
- package/dist/core/viewer/btnViewer/index.js.map +0 -1
- package/dist/core/viewer/checkViewer/index.js.map +0 -1
- package/dist/core/viewer/editViewer/index.js.map +0 -1
- package/dist/core/viewer/groupViewer/index.js.map +0 -1
- package/dist/core/viewer/index.js.map +0 -1
- package/dist/core/viewer/switchViewer/index.js.map +0 -1
- package/dist/example/antComponent.js.map +0 -1
- package/dist/example/basic.js.map +0 -1
- package/dist/example/ellipsis.js.map +0 -1
- package/dist/example/fixed.js.map +0 -1
- package/dist/example/group.js.map +0 -1
- package/dist/example/selection.js.map +0 -1
- package/dist/example/sheet.js.map +0 -1
- package/dist/example/valuationAnalyze.js.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/useEventBus.js.map +0 -1
- package/dist/hooks/useKeyboard.js.map +0 -1
- package/dist/hooks/useMiddlewareReducer.js.map +0 -1
- package/dist/hooks/useMouse.js.map +0 -1
- package/dist/hooks/useSetState.js.map +0 -1
- package/dist/hooks/useSheetEvent.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/standardUtils/index.js.map +0 -1
- package/dist/type/index.js.map +0 -1
- package/dist/type/sheet.js.map +0 -1
- package/dist/type/sheetTable.js.map +0 -1
package/dist/example/sheet.js
CHANGED
|
@@ -53,7 +53,7 @@ var ExcelIndexCell = function ExcelIndexCell(_ref) {
|
|
|
53
53
|
var grid = range(1, 120).map(function (row, rowIndex) {
|
|
54
54
|
return range(0, 26).map(function (i) {
|
|
55
55
|
return {
|
|
56
|
-
id: String(random(0, 1)),
|
|
56
|
+
id: String(random(0, 1, true)),
|
|
57
57
|
readonly: i === 0 ? true : false,
|
|
58
58
|
fixed: i === 0 ? 'left' : undefined,
|
|
59
59
|
value: i === 0 ? row : row > 15 || i > 10 ? '' : "".concat(row, "-").concat(i),
|
|
@@ -180,8 +180,8 @@ var BasicSheet = function BasicSheet() {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
}, [state, groupConfig]);
|
|
183
|
-
var onCellsChanged = function
|
|
184
|
-
var newGrid =
|
|
183
|
+
var onCellsChanged = useCallback(function (changes, extChanges) {
|
|
184
|
+
var newGrid = cloneDeep(state);
|
|
185
185
|
changes.forEach(function (_ref4) {
|
|
186
186
|
var row = _ref4.row,
|
|
187
187
|
col = _ref4.col,
|
|
@@ -192,8 +192,45 @@ var BasicSheet = function BasicSheet() {
|
|
|
192
192
|
});
|
|
193
193
|
newGrid[row] = newRow;
|
|
194
194
|
});
|
|
195
|
+
extChanges === null || extChanges === void 0 ? void 0 : extChanges.forEach(function (item) {
|
|
196
|
+
var _ref5 = item,
|
|
197
|
+
row = _ref5.row,
|
|
198
|
+
col = _ref5.col,
|
|
199
|
+
value = _ref5.value;
|
|
200
|
+
if (!newGrid[row]) {
|
|
201
|
+
var newRow = cloneDeep(newGrid[0]);
|
|
202
|
+
newRow.forEach(function (item) {
|
|
203
|
+
item.value = '';
|
|
204
|
+
item.record = undefined;
|
|
205
|
+
item.id = String(random(0, 1, true));
|
|
206
|
+
});
|
|
207
|
+
newGrid.push(newRow);
|
|
208
|
+
newGrid.forEach(function (row, index) {
|
|
209
|
+
row[0].value = index + 1;
|
|
210
|
+
});
|
|
211
|
+
// sheetInstance.current?.pushToHistory({
|
|
212
|
+
// type: 'NewRow' as SheetType.OperateType,
|
|
213
|
+
// changes: [],
|
|
214
|
+
// rowInfo: {
|
|
215
|
+
// newRow: index + 1,
|
|
216
|
+
// },
|
|
217
|
+
// extraInfo: groupConfig,
|
|
218
|
+
// });
|
|
219
|
+
// const newRow = Array(newGrid[0].length).map((item, index) => ({
|
|
220
|
+
// id: String(random(0, 1)),
|
|
221
|
+
// row,
|
|
222
|
+
// col: index,
|
|
223
|
+
// value: '',
|
|
224
|
+
// }));
|
|
225
|
+
// newGrid.push(newRow);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
newGrid[row][col] = _objectSpread(_objectSpread({}, newGrid[row][col]), {}, {
|
|
229
|
+
value: value
|
|
230
|
+
});
|
|
231
|
+
});
|
|
195
232
|
setState(newGrid);
|
|
196
|
-
};
|
|
233
|
+
}, [state]);
|
|
197
234
|
var WrappedTableShell = useMemo(function () {
|
|
198
235
|
return DraggableShell({
|
|
199
236
|
columns: range(26).map(function (i) {
|
|
@@ -216,9 +253,9 @@ var BasicSheet = function BasicSheet() {
|
|
|
216
253
|
var position = props.position,
|
|
217
254
|
handleMenu = props.onContextMenu,
|
|
218
255
|
cell = props.cell;
|
|
219
|
-
var
|
|
220
|
-
top =
|
|
221
|
-
left =
|
|
256
|
+
var _ref6 = position || {},
|
|
257
|
+
top = _ref6.top,
|
|
258
|
+
left = _ref6.left;
|
|
222
259
|
if (!cell) return null;
|
|
223
260
|
return /*#__PURE__*/_jsxs("div", {
|
|
224
261
|
className: "harvest-menu",
|
|
@@ -261,9 +298,9 @@ var BasicSheet = function BasicSheet() {
|
|
|
261
298
|
});
|
|
262
299
|
}, [handleNewRow]);
|
|
263
300
|
var handleMenuClick = useCallback(function (e) {
|
|
264
|
-
var
|
|
265
|
-
type =
|
|
266
|
-
row =
|
|
301
|
+
var _ref7 = e,
|
|
302
|
+
type = _ref7.type,
|
|
303
|
+
row = _ref7.row;
|
|
267
304
|
console.log('click', state.length);
|
|
268
305
|
if (type === '1') {
|
|
269
306
|
handleNewRow(row);
|
|
@@ -275,15 +312,15 @@ var BasicSheet = function BasicSheet() {
|
|
|
275
312
|
handleDeleteRow(row);
|
|
276
313
|
}
|
|
277
314
|
}, [state, groupConfig]);
|
|
278
|
-
console.log('render', performance.now());
|
|
279
315
|
useEffect(function () {
|
|
280
316
|
console.log('rendered', performance.now());
|
|
281
317
|
}, []);
|
|
282
|
-
console.log(state.length);
|
|
283
318
|
return /*#__PURE__*/_jsxs(Sheet, {
|
|
284
319
|
sheetInstance: sheetInstance,
|
|
285
320
|
className: "excel-sheet",
|
|
286
321
|
virtualized: true,
|
|
322
|
+
freePaste: true,
|
|
323
|
+
showBackEdit: true,
|
|
287
324
|
data: state,
|
|
288
325
|
groupConfig: groupConfig,
|
|
289
326
|
scroll: {
|
|
@@ -297,8 +334,8 @@ var BasicSheet = function BasicSheet() {
|
|
|
297
334
|
children: [/*#__PURE__*/_jsx(SheetEvent, {
|
|
298
335
|
name: "onCellClick",
|
|
299
336
|
handler: function handler(e) {
|
|
300
|
-
var
|
|
301
|
-
row =
|
|
337
|
+
var _ref8 = e,
|
|
338
|
+
row = _ref8.row;
|
|
302
339
|
var index = groupConfig.groups.findIndex(function (item) {
|
|
303
340
|
return item.groupStart === row;
|
|
304
341
|
});
|
|
@@ -353,5 +390,4 @@ var BasicSheet = function BasicSheet() {
|
|
|
353
390
|
})]
|
|
354
391
|
});
|
|
355
392
|
};
|
|
356
|
-
export default BasicSheet;
|
|
357
|
-
//# sourceMappingURL=sheet.js.map
|
|
393
|
+
export default BasicSheet;
|
|
@@ -5,8 +5,11 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
5
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
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import { getNumberEditor, getSelectEditor, Table } from "./..";
|
|
8
|
+
import { Button } from 'antd';
|
|
9
|
+
import { isNil } from 'lodash';
|
|
8
10
|
import { useCallback, useState } from 'react';
|
|
9
11
|
import { SwitchViewer } from "../core/viewer";
|
|
12
|
+
import { SheetType } from "../type";
|
|
10
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
14
|
var RateValueInput = getNumberEditor({
|
|
12
15
|
addonAfter: '%',
|
|
@@ -50,14 +53,15 @@ var data = [{
|
|
|
50
53
|
totalValuation: 1429232708.3536763,
|
|
51
54
|
isEnabled: false
|
|
52
55
|
}];
|
|
56
|
+
var evaluateMethods = [{
|
|
57
|
+
label: 'DCF',
|
|
58
|
+
value: 2
|
|
59
|
+
}, {
|
|
60
|
+
label: 'T&R',
|
|
61
|
+
value: 5
|
|
62
|
+
}];
|
|
63
|
+
var EvaSelect = getSelectEditor(evaluateMethods);
|
|
53
64
|
export default (function () {
|
|
54
|
-
var evaluateMethods = [{
|
|
55
|
-
label: 'DCF',
|
|
56
|
-
value: 2
|
|
57
|
-
}, {
|
|
58
|
-
label: 'T&R',
|
|
59
|
-
value: 5
|
|
60
|
-
}];
|
|
61
65
|
var _useState = useState(data),
|
|
62
66
|
_useState2 = _slicedToArray(_useState, 1),
|
|
63
67
|
state = _useState2[0];
|
|
@@ -105,7 +109,7 @@ export default (function () {
|
|
|
105
109
|
dataIndex: 'termDiscountRate',
|
|
106
110
|
width: 134,
|
|
107
111
|
editor: RateValueInput,
|
|
108
|
-
|
|
112
|
+
render: RateViewer,
|
|
109
113
|
readonly: function readonly(value, record, row) {
|
|
110
114
|
return !row || isNil(record.valuationType);
|
|
111
115
|
}
|
|
@@ -114,7 +118,7 @@ export default (function () {
|
|
|
114
118
|
title: '租期外折现率',
|
|
115
119
|
dataIndex: 'reversionDiscountRate',
|
|
116
120
|
width: 134,
|
|
117
|
-
|
|
121
|
+
render: RateViewer,
|
|
118
122
|
editor: RateValueInput,
|
|
119
123
|
readonly: function readonly(value, record, row) {
|
|
120
124
|
return !row || isNil(record.valuationType);
|
|
@@ -123,7 +127,7 @@ export default (function () {
|
|
|
123
127
|
title: '空置面积折现率',
|
|
124
128
|
dataIndex: 'vacancyDiscountRate',
|
|
125
129
|
width: 134,
|
|
126
|
-
|
|
130
|
+
render: RateViewer,
|
|
127
131
|
editor: RateValueInput,
|
|
128
132
|
readonly: function readonly(value, record, row) {
|
|
129
133
|
return !row || isNil(record.valuationType);
|
|
@@ -132,8 +136,8 @@ export default (function () {
|
|
|
132
136
|
title: '折现率',
|
|
133
137
|
dataIndex: 'discountRate',
|
|
134
138
|
width: 134,
|
|
135
|
-
|
|
136
|
-
editor:
|
|
139
|
+
render: RateViewer,
|
|
140
|
+
editor: EvaSelect,
|
|
137
141
|
readonly: function readonly(value, record, row) {
|
|
138
142
|
return !row || isNil(record.valuationType);
|
|
139
143
|
}
|
|
@@ -141,7 +145,7 @@ export default (function () {
|
|
|
141
145
|
title: '退出资本化率',
|
|
142
146
|
dataIndex: 'exitCapRate',
|
|
143
147
|
width: 134,
|
|
144
|
-
|
|
148
|
+
render: RateViewer,
|
|
145
149
|
editor: RateValueInput,
|
|
146
150
|
readonly: function readonly(value, record, row) {
|
|
147
151
|
return !row || isNil(record.valuationType);
|
|
@@ -168,7 +172,7 @@ export default (function () {
|
|
|
168
172
|
title: '操作',
|
|
169
173
|
width: 62,
|
|
170
174
|
dataIndex: 'id',
|
|
171
|
-
|
|
175
|
+
fixed: SheetType.CellAlign.right,
|
|
172
176
|
editable: false,
|
|
173
177
|
render: function (props) {
|
|
174
178
|
var row = props.row,
|
|
@@ -178,11 +182,10 @@ export default (function () {
|
|
|
178
182
|
children: /*#__PURE__*/_jsx(Button, {
|
|
179
183
|
type: "link",
|
|
180
184
|
onClick: function onClick() {
|
|
181
|
-
handleDelete(record.id);
|
|
185
|
+
// handleDelete((record as { id: number }).id);
|
|
182
186
|
// const infos = [{ id: record.id, row, extra: record }];
|
|
183
187
|
// operateCb && operateCb(4, { row, infos });
|
|
184
188
|
},
|
|
185
|
-
|
|
186
189
|
size: "small",
|
|
187
190
|
children: "\u5220\u9664"
|
|
188
191
|
})
|
|
@@ -221,5 +224,4 @@ export default (function () {
|
|
|
221
224
|
dataSource: state,
|
|
222
225
|
onChange: handleChange
|
|
223
226
|
});
|
|
224
|
-
});
|
|
225
|
-
//# sourceMappingURL=valuationAnalyze.js.map
|
|
227
|
+
});
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export type { Dispatch, FunctionAction, NormalAction, } from './useMiddlewareRed
|
|
|
5
5
|
export { useMouse } from './useMouse';
|
|
6
6
|
export { useSetState } from './useSetState';
|
|
7
7
|
export { SheetEventContext, useSheetEvent } from './useSheetEvent';
|
|
8
|
+
export { useWidth, WidthContext } from './useWidthConfig';
|
package/dist/hooks/index.js
CHANGED
|
@@ -4,4 +4,4 @@ export { useMiddlewareReducer } from "./useMiddlewareReducer";
|
|
|
4
4
|
export { useMouse } from "./useMouse";
|
|
5
5
|
export { useSetState } from "./useSetState";
|
|
6
6
|
export { SheetEventContext, useSheetEvent } from "./useSheetEvent";
|
|
7
|
-
|
|
7
|
+
export { useWidth, WidthContext } from "./useWidthConfig";
|
package/dist/hooks/useMouse.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { debounce } from 'lodash';
|
|
2
|
-
import { useCallback, useEffect } from 'react';
|
|
2
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
3
3
|
export var useMouse = function useMouse(handler, listenElement) {
|
|
4
4
|
var mouseUp = handler.mouseUp,
|
|
5
5
|
mouseDown = handler.mouseDown,
|
|
@@ -8,6 +8,7 @@ export var useMouse = function useMouse(handler, listenElement) {
|
|
|
8
8
|
mouseEnter = handler.mouseEnter,
|
|
9
9
|
doubleClick = handler.doubleClick,
|
|
10
10
|
loseFocus = handler.loseFocus;
|
|
11
|
+
var handlerRef = useRef();
|
|
11
12
|
|
|
12
13
|
// todo
|
|
13
14
|
var wrapper = useCallback(function (handle) {
|
|
@@ -18,36 +19,50 @@ export var useMouse = function useMouse(handler, listenElement) {
|
|
|
18
19
|
handle(e);
|
|
19
20
|
};
|
|
20
21
|
}, [listenElement]);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
+
}, []);
|
|
25
40
|
useEffect(function () {
|
|
26
41
|
if (!listenElement) return;
|
|
27
42
|
var debounceOver = debounce(mouseOver, 10);
|
|
28
43
|
var wrappedMouseUp = mouseUp;
|
|
29
44
|
var wrappedMouseDown = function wrappedMouseDown(e) {
|
|
30
|
-
if (!listenElement.contains(e.target)) {
|
|
45
|
+
if (!(listenElement !== null && listenElement !== void 0 && listenElement.contains(e.target))) {
|
|
31
46
|
loseFocus(e);
|
|
32
47
|
return;
|
|
33
48
|
}
|
|
34
49
|
mouseDown(e);
|
|
35
50
|
};
|
|
36
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
|
+
};
|
|
37
61
|
document.addEventListener('mouseup', wrappedMouseUp);
|
|
38
62
|
document.addEventListener('mousedown', wrappedMouseDown);
|
|
39
63
|
document.addEventListener('dblclick', wrappedMouseDoubleClick);
|
|
40
|
-
listenElement.addEventListener('mouseover', debounceOver);
|
|
41
|
-
listenElement.addEventListener('mouseleave', mouseLeave);
|
|
42
|
-
listenElement.addEventListener('mouseenter', mouseEnter);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
listenElement.removeEventListener('mouseleave', mouseLeave);
|
|
46
|
-
listenElement.removeEventListener('mouseenter', mouseEnter);
|
|
47
|
-
document.removeEventListener('mousedown', wrappedMouseUp);
|
|
48
|
-
document.removeEventListener('mouseup', wrappedMouseDown);
|
|
49
|
-
document.removeEventListener('dblclick', wrappedMouseDoubleClick);
|
|
50
|
-
};
|
|
51
|
-
}, [listenElement, mouseUp, mouseDown, mouseOver, mouseLeave, doubleClick, loseFocus]);
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=useMouse.js.map
|
|
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
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { SheetTableType, SheetType } from './type';
|
|
1
2
|
export * from './core/editor';
|
|
2
3
|
export { default as Sheet } from './core/sheet';
|
|
3
4
|
export { default as Table } from './core/table';
|
|
5
|
+
export * from './core/viewer';
|
|
6
|
+
export * from './hooks';
|
|
4
7
|
export { useSheetEvent } from './hooks/useSheetEvent';
|
|
8
|
+
export { SheetTableType, SheetType };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { SheetTableType, SheetType } from "./type";
|
|
1
2
|
export * from "./core/editor";
|
|
2
3
|
export { default as Sheet } from "./core/sheet";
|
|
3
4
|
export { default as Table } from "./core/table";
|
|
5
|
+
export * from "./core/viewer";
|
|
6
|
+
export * from "./hooks";
|
|
4
7
|
export { useSheetEvent } from "./hooks/useSheetEvent";
|
|
5
|
-
|
|
8
|
+
export { SheetTableType, SheetType };
|
|
@@ -24,10 +24,9 @@ export var thousandsSeparator = function thousandsSeparator(value) {
|
|
|
24
24
|
_String$split2 = _slicedToArray(_String$split, 2),
|
|
25
25
|
integer = _String$split2[0],
|
|
26
26
|
decimal = _String$split2[1];
|
|
27
|
-
var formattedData = integer.replace(/(\d{1,3})(?=(\d{3})+$)/g, '$1,');
|
|
27
|
+
var formattedData = integer === null || integer === void 0 ? void 0 : integer.replace(/(\d{1,3})(?=(\d{3})+$)/g, '$1,');
|
|
28
28
|
if (decimal && decimal.length) {
|
|
29
29
|
formattedData += ".".concat(decimal);
|
|
30
30
|
}
|
|
31
31
|
return formattedData;
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
|
32
|
+
};
|
package/dist/type/index.js
CHANGED
package/dist/type/sheet.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { EventEmitter } from 'events';
|
|
4
|
-
import { SheetTableType } from '.';
|
|
4
|
+
import { SheetTableType, SheetType } from '.';
|
|
5
5
|
export declare enum CellAlign {
|
|
6
6
|
left = "left",
|
|
7
7
|
center = "center",
|
|
@@ -40,8 +40,9 @@ export declare type CellEditorProps = {
|
|
|
40
40
|
onConfirm: (value: unknown) => void;
|
|
41
41
|
} & CellViewerProps;
|
|
42
42
|
export declare type CellEditor = React.FC<CellEditorProps> & {
|
|
43
|
-
checker?: (value: unknown) => boolean;
|
|
44
|
-
formatter?: (value: unknown) => unknown;
|
|
43
|
+
checker?: (value: unknown, record?: Record<string, unknown>) => boolean;
|
|
44
|
+
formatter?: (value: unknown, record?: Record<string, unknown>) => unknown;
|
|
45
|
+
parser?: (value: unknown, record?: Record<string, unknown>) => unknown;
|
|
45
46
|
};
|
|
46
47
|
export declare type CellViewer = React.FC<CellViewerProps>;
|
|
47
48
|
export declare type CellPosition = {
|
|
@@ -78,6 +79,10 @@ export declare type SheetInstance = {
|
|
|
78
79
|
zoomTo: (row?: number) => void;
|
|
79
80
|
pushToHistory: (value: OperateHistory) => void;
|
|
80
81
|
selectRow: (row?: number) => void;
|
|
82
|
+
select: (props: {
|
|
83
|
+
start: SheetType.CellPosition;
|
|
84
|
+
end: SheetType.CellPosition;
|
|
85
|
+
}) => void;
|
|
81
86
|
popHistory: () => OperateHistory;
|
|
82
87
|
};
|
|
83
88
|
export declare type SheetProps = {
|
|
@@ -88,6 +93,8 @@ export declare type SheetProps = {
|
|
|
88
93
|
data: Cell[][];
|
|
89
94
|
freePaste?: boolean;
|
|
90
95
|
virtualized?: boolean;
|
|
96
|
+
showBackEdit?: boolean;
|
|
97
|
+
backEditStyle?: Partial<CSSStyleDeclaration>;
|
|
91
98
|
groupConfig?: RowGroupConfig;
|
|
92
99
|
onCellsChanged?: CellChangeHandler;
|
|
93
100
|
menuRenderer?: React.FC<MenuRenderProps>;
|
|
@@ -99,6 +106,10 @@ export declare type SheetProps = {
|
|
|
99
106
|
rowClassName?: string | ((record: Record<string, unknown>, index: number) => string);
|
|
100
107
|
children?: any[];
|
|
101
108
|
};
|
|
109
|
+
export declare type WidthConfig = {
|
|
110
|
+
onChange?: (value: Record<number | string, number>) => void;
|
|
111
|
+
widths?: Record<number | string, number>;
|
|
112
|
+
};
|
|
102
113
|
export declare type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
|
|
103
114
|
className?: string;
|
|
104
115
|
showGroup?: boolean;
|
package/dist/type/sheet.js
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { SheetType } from '.';
|
|
3
3
|
export declare type refAssertion = {
|
|
4
4
|
contains?: (target: EventTarget | null) => boolean;
|
|
5
5
|
focus?: () => boolean;
|
|
6
6
|
} & HTMLTableSectionElement;
|
|
7
7
|
export declare type CellFixed = SheetType.CellAlign;
|
|
8
|
+
export declare type RecordRowMap<T> = (value: unknown, record: Record<string, unknown>, index: number) => T;
|
|
8
9
|
export declare type ColumnProps = {
|
|
10
|
+
/**
|
|
11
|
+
* @description 对齐
|
|
12
|
+
* @default "left"
|
|
13
|
+
*/
|
|
9
14
|
align?: SheetType.CellAlign;
|
|
15
|
+
/**
|
|
16
|
+
* @description 固定
|
|
17
|
+
* @default "undefined"
|
|
18
|
+
*/
|
|
10
19
|
fixed?: Omit<CellFixed, 'center'>;
|
|
20
|
+
/**
|
|
21
|
+
* @description 列宽
|
|
22
|
+
* @default "undefined"
|
|
23
|
+
*/
|
|
11
24
|
width?: string | number;
|
|
12
25
|
dataIndex?: string;
|
|
13
|
-
title: string;
|
|
26
|
+
title: string | ReactNode | ReactNode[];
|
|
27
|
+
titleConfig?: {
|
|
28
|
+
colSpan?: number;
|
|
29
|
+
className?: string;
|
|
30
|
+
};
|
|
31
|
+
cellConfig?: {
|
|
32
|
+
className?: string | RecordRowMap<string>;
|
|
33
|
+
};
|
|
14
34
|
key?: string;
|
|
15
|
-
editable?: boolean
|
|
16
|
-
readonly?: boolean |
|
|
35
|
+
editable?: boolean | RecordRowMap<boolean>;
|
|
36
|
+
readonly?: boolean | RecordRowMap<boolean>;
|
|
17
37
|
render?: SheetType.CellViewer;
|
|
18
38
|
editor?: SheetType.CellEditor;
|
|
19
39
|
};
|
|
@@ -24,13 +44,25 @@ export declare type TableChange = {
|
|
|
24
44
|
value: unknown;
|
|
25
45
|
};
|
|
26
46
|
export declare type TableRowSelection = {
|
|
27
|
-
|
|
47
|
+
rowSelected?: string[];
|
|
48
|
+
onChange?: (selectedRowKeys: string[], selectedRows: Record<string, unknown>[]) => void;
|
|
28
49
|
};
|
|
29
50
|
export declare type TableGroupConfig = {
|
|
30
|
-
defaultOpen
|
|
51
|
+
defaultOpen?: boolean;
|
|
52
|
+
rowGroup?: SheetType.RowGroupConfig;
|
|
53
|
+
onChange?: (value: SheetType.RowGroupConfig) => void;
|
|
31
54
|
};
|
|
55
|
+
export declare type EventHandler = (value: any) => void;
|
|
32
56
|
export declare type TableProps = {
|
|
57
|
+
/**
|
|
58
|
+
* @description 表格类名
|
|
59
|
+
* @default "undefined"
|
|
60
|
+
*/
|
|
33
61
|
className?: string;
|
|
62
|
+
/**
|
|
63
|
+
* @description sheet的一些定义方法可执行
|
|
64
|
+
* @default "object"
|
|
65
|
+
*/
|
|
34
66
|
sheetInstance?: React.MutableRefObject<SheetType.SheetInstance | null>;
|
|
35
67
|
columns: ColumnProps[];
|
|
36
68
|
virtualized?: boolean;
|
|
@@ -43,15 +75,12 @@ export declare type TableProps = {
|
|
|
43
75
|
};
|
|
44
76
|
sticky?: boolean;
|
|
45
77
|
draggable?: boolean;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
groupConfig?:
|
|
51
|
-
|
|
52
|
-
onChange: (value: TableGroupConfig) => void;
|
|
53
|
-
};
|
|
54
|
-
onChange: (changes: TableChange[]) => void;
|
|
78
|
+
freePaste?: boolean;
|
|
79
|
+
showBackEdit?: boolean;
|
|
80
|
+
backEditStyle?: Partial<CSSStyleDeclaration>;
|
|
81
|
+
rowSelection?: TableRowSelection;
|
|
82
|
+
groupConfig?: TableGroupConfig;
|
|
83
|
+
onChange: (changes: TableChange[], extChanges?: TableChange[]) => void;
|
|
55
84
|
handleAdd?: () => void;
|
|
56
|
-
eventHandler?: Record<'btn-click' | 'cell-edit' | 'cell-switch' | string, undefined |
|
|
85
|
+
eventHandler?: Record<'reverse' | 'btn-click' | 'cell-edit' | 'cell-switch' | string, undefined | EventHandler>;
|
|
57
86
|
};
|
package/dist/type/sheetTable.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=sheetTable.js.map
|
|
1
|
+
export {};
|
package/package.json
CHANGED
package/dist/core/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["TAB_KEY","ENTER_KEY","ESCAPE_KEY","LEFT_KEY","UP_KEY","RIGHT_KEY","DOWN_KEY","DELETE_KEY","BACKSPACE_KEY","Z_KEY","C_KEY","V_KEY","X_KEY"],"sources":["../../src/core/config.ts"],"sourcesContent":["export const TAB_KEY = 9;\nexport const ENTER_KEY = 13;\nexport const ESCAPE_KEY = 27;\nexport const LEFT_KEY = 37;\nexport const UP_KEY = 38;\nexport const RIGHT_KEY = 39;\nexport const DOWN_KEY = 40;\nexport const DELETE_KEY = 46;\nexport const BACKSPACE_KEY = 8;\nexport const Z_KEY = 90;\nexport const C_KEY = 67;\nexport const V_KEY = 86;\nexport const X_KEY = 88;\n"],"mappings":"AAAA,OAAO,IAAMA,OAAO,GAAG,CAAC;AACxB,OAAO,IAAMC,SAAS,GAAG,EAAE;AAC3B,OAAO,IAAMC,UAAU,GAAG,EAAE;AAC5B,OAAO,IAAMC,QAAQ,GAAG,EAAE;AAC1B,OAAO,IAAMC,MAAM,GAAG,EAAE;AACxB,OAAO,IAAMC,SAAS,GAAG,EAAE;AAC3B,OAAO,IAAMC,QAAQ,GAAG,EAAE;AAC1B,OAAO,IAAMC,UAAU,GAAG,EAAE;AAC5B,OAAO,IAAMC,aAAa,GAAG,CAAC;AAC9B,OAAO,IAAMC,KAAK,GAAG,EAAE;AACvB,OAAO,IAAMC,KAAK,GAAG,EAAE;AACvB,OAAO,IAAMC,KAAK,GAAG,EAAE;AACvB,OAAO,IAAMC,KAAK,GAAG,EAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Cascader","useMemo","optionsTransferToValue","jsx","_jsx","getCascaderEditor","options","CascaderEditor","props","value","onConfirm","val","handleChange","opt","console","log","length","autoFocus","open","className","onMouseDown","event","stopPropagation","displayRender","label","onChange","checker","res"],"sources":["../../../../src/core/editor/cascaderEditor/index.tsx"],"sourcesContent":["import type { SheetType } from '@zhenliang/sheet/type';\nimport { Cascader } from 'antd';\nimport 'antd/es/cascader/style/index.css';\nimport { useMemo } from 'react';\nimport { optionsTransferToValue } from '../../util';\nimport './index.less';\n\nconst getCascaderEditor = (options: SheetType.OptionsType[]) => {\n const CascaderEditor: SheetType.CellEditor = (props) => {\n const { value, onConfirm } = props;\n\n const val = useMemo(\n () => optionsTransferToValue(options, value as string),\n [value, options],\n );\n\n const handleChange = (opt: any) => {\n console.log(opt);\n onConfirm(opt ? opt[opt.length - 1] : null);\n };\n\n return (\n <Cascader\n autoFocus\n open\n className={'cascader-editor'}\n onMouseDown={(event: any) => {\n event.stopPropagation();\n }}\n value={val}\n // allowClear={false}\n displayRender={(label) => label[label.length - 1]}\n onChange={handleChange}\n // onBlur={handleBlur}\n // onKeyDown={handleKeyDown}\n options={options}\n />\n );\n };\n\n CascaderEditor.checker = (value) => {\n const res = optionsTransferToValue(options, value as string);\n return res && res.length > 0;\n };\n return CascaderEditor;\n};\nexport default getCascaderEditor;\n"],"mappings":"AACA,SAASA,QAAQ,QAAQ,MAAM;AAC/B,OAAO,kCAAkC;AACzC,SAASC,OAAO,QAAQ,OAAO;AAC/B,SAASC,sBAAsB;AAC/B;AAAsB,SAAAC,GAAA,IAAAC,IAAA;AAEtB,IAAMC,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIC,OAAgC,EAAK;EAC9D,IAAMC,cAAoC,GAAG,SAAvCA,cAAoCA,CAAIC,KAAK,EAAK;IACtD,IAAQC,KAAK,GAAgBD,KAAK,CAA1BC,KAAK;MAAEC,SAAS,GAAKF,KAAK,CAAnBE,SAAS;IAExB,IAAMC,GAAG,GAAGV,OAAO,CACjB;MAAA,OAAMC,sBAAsB,CAACI,OAAO,EAAEG,KAAe,CAAC;IAAA,GACtD,CAACA,KAAK,EAAEH,OAAO,CACjB,CAAC;IAED,IAAMM,YAAY,GAAG,SAAfA,YAAYA,CAAIC,GAAQ,EAAK;MACjCC,OAAO,CAACC,GAAG,CAACF,GAAG,CAAC;MAChBH,SAAS,CAACG,GAAG,GAAGA,GAAG,CAACA,GAAG,CAACG,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;IAC7C,CAAC;IAED,oBACEZ,IAAA,CAACJ,QAAQ;MACPiB,SAAS;MACTC,IAAI;MACJC,SAAS,EAAE,iBAAkB;MAC7BC,WAAW,EAAE,SAAAA,YAACC,KAAU,EAAK;QAC3BA,KAAK,CAACC,eAAe,CAAC,CAAC;MACzB,CAAE;MACFb,KAAK,EAAEE;MACP;MAAA;MACAY,aAAa,EAAE,SAAAA,cAACC,KAAK;QAAA,OAAKA,KAAK,CAACA,KAAK,CAACR,MAAM,GAAG,CAAC,CAAC;MAAA,CAAC;MAClDS,QAAQ,EAAEb;MACV;MACA;MAAA;MACAN,OAAO,EAAEA;IAAQ,CAClB,CAAC;EAEN,CAAC;EAEDC,cAAc,CAACmB,OAAO,GAAG,UAACjB,KAAK,EAAK;IAClC,IAAMkB,GAAG,GAAGzB,sBAAsB,CAACI,OAAO,EAAEG,KAAe,CAAC;IAC5D,OAAOkB,GAAG,IAAIA,GAAG,CAACX,MAAM,GAAG,CAAC;EAC9B,CAAC;EACD,OAAOT,cAAc;AACvB,CAAC;AACD,eAAeF,iBAAiB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["DatePicker","moment","useEffect","useMemo","useRef","jsx","_jsx","DateEditor","props","value","onChange","onConfirm","dateRef","_dateRef$current","current","focus","val","handleChange","format","open","ref","className","onMouseDown","e","stopPropagation","checker","reg","test","formatter","_DateEditor$checker","call","replace"],"sources":["../../../../src/core/editor/dateEditor/index.tsx"],"sourcesContent":["import { DatePicker } from 'antd';\nimport 'antd/es/date-picker/style/index.css';\n\nimport type { SheetType } from '@zhenliang/sheet/type';\nimport moment from 'moment';\nimport { useEffect, useMemo, useRef } from 'react';\nimport './index.less';\n\nexport const DateEditor: SheetType.CellEditor = (props) => {\n const { value, onChange, onConfirm } = props;\n const dateRef = useRef<any>(null);\n\n useEffect(() => {\n dateRef?.current?.focus();\n }, []);\n\n const val = useMemo(() => value && moment(value as string), [value]);\n\n const handleChange = (value: any) => {\n onChange(value?.format('YYYY-MM-DD'));\n onConfirm(value?.format('YYYY-MM-DD'));\n };\n\n return (\n <DatePicker\n open\n ref={dateRef}\n className=\"date-editor\"\n value={val as any}\n onMouseDown={(e) => e.stopPropagation()}\n onChange={handleChange}\n />\n );\n};\n\nDateEditor.checker = (value) => {\n const reg = /^[1-9]\\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/;\n return reg.test(value as string);\n};\n\nDateEditor.formatter = (value) => {\n if (!DateEditor?.checker?.(value)) return null;\n return (value as string).replace('/', '-').replace('/', '-');\n};\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,MAAM;AACjC,OAAO,qCAAqC;AAG5C,OAAOC,MAAM,MAAM,QAAQ;AAC3B,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAClD;AAAsB,SAAAC,GAAA,IAAAC,IAAA;AAEtB,OAAO,IAAMC,UAAgC,GAAG,SAAnCA,UAAgCA,CAAIC,KAAK,EAAK;EACzD,IAAQC,KAAK,GAA0BD,KAAK,CAApCC,KAAK;IAAEC,QAAQ,GAAgBF,KAAK,CAA7BE,QAAQ;IAAEC,SAAS,GAAKH,KAAK,CAAnBG,SAAS;EAClC,IAAMC,OAAO,GAAGR,MAAM,CAAM,IAAI,CAAC;EAEjCF,SAAS,CAAC,YAAM;IAAA,IAAAW,gBAAA;IACdD,OAAO,aAAPA,OAAO,wBAAAC,gBAAA,GAAPD,OAAO,CAAEE,OAAO,cAAAD,gBAAA,uBAAhBA,gBAAA,CAAkBE,KAAK,CAAC,CAAC;EAC3B,CAAC,EAAE,EAAE,CAAC;EAEN,IAAMC,GAAG,GAAGb,OAAO,CAAC;IAAA,OAAMM,KAAK,IAAIR,MAAM,CAACQ,KAAe,CAAC;EAAA,GAAE,CAACA,KAAK,CAAC,CAAC;EAEpE,IAAMQ,YAAY,GAAG,SAAfA,YAAYA,CAAIR,KAAU,EAAK;IACnCC,QAAQ,CAACD,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAES,MAAM,CAAC,YAAY,CAAC,CAAC;IACrCP,SAAS,CAACF,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAES,MAAM,CAAC,YAAY,CAAC,CAAC;EACxC,CAAC;EAED,oBACEZ,IAAA,CAACN,UAAU;IACTmB,IAAI;IACJC,GAAG,EAAER,OAAQ;IACbS,SAAS,EAAC,aAAa;IACvBZ,KAAK,EAAEO,GAAW;IAClBM,WAAW,EAAE,SAAAA,YAACC,CAAC;MAAA,OAAKA,CAAC,CAACC,eAAe,CAAC,CAAC;IAAA,CAAC;IACxCd,QAAQ,EAAEO;EAAa,CACxB,CAAC;AAEN,CAAC;AAEDV,UAAU,CAACkB,OAAO,GAAG,UAAChB,KAAK,EAAK;EAC9B,IAAMiB,GAAG,GAAG,yDAAyD;EACrE,OAAOA,GAAG,CAACC,IAAI,CAAClB,KAAe,CAAC;AAClC,CAAC;AAEDF,UAAU,CAACqB,SAAS,GAAG,UAACnB,KAAK,EAAK;EAAA,IAAAoB,mBAAA;EAChC,IAAI,EAACtB,UAAU,aAAVA,UAAU,gBAAAsB,mBAAA,GAAVtB,UAAU,CAAEkB,OAAO,cAAAI,mBAAA,eAAnBA,mBAAA,CAAAC,IAAA,CAAAvB,UAAU,EAAYE,KAAK,CAAC,GAAE,OAAO,IAAI;EAC9C,OAAQA,KAAK,CAAYsB,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;AAC9D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["default","getCascaderEditor","DateEditor","getNumberEditor","NumberEditor","getSelectEditor"],"sources":["../../../src/core/editor/index.ts"],"sourcesContent":["export { default as getCascaderEditor } from './cascaderEditor';\nexport { DateEditor } from './dateEditor';\nexport { getNumberEditor, NumberEditor } from './numberEditor';\nexport { default as getSelectEditor } from './selectEditor';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,iBAAiB;AACrC,SAASC,UAAU;AACnB,SAASC,eAAe,EAAEC,YAAY;AACtC,SAASJ,OAAO,IAAIK,eAAe"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["InputNumber","AntInputNumber","useEffect","useRef","jsx","_jsx","NumberEditor","props","value","onChange","inputNumberRef","_inputNumberRef$curre","current","focus","ref","controls","className","onMouseDown","e","stopPropagation","addonAfter","getNumberEditor","extraProps","_inputNumberRef$curre2","_objectSpread"],"sources":["../../../../src/core/editor/numberEditor/index.tsx"],"sourcesContent":["import type { SheetType } from '@zhenliang/sheet/type';\nimport { InputNumber as AntInputNumber, InputNumberProps } from 'antd';\nimport 'antd/es/input-number/style/index.css';\nimport { useEffect, useRef } from 'react';\nimport './index.less';\n\nexport const NumberEditor: SheetType.CellEditor = (props) => {\n const { value, onChange } = props;\n const inputNumberRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n inputNumberRef?.current?.focus();\n }, []);\n\n return (\n <AntInputNumber\n ref={inputNumberRef}\n controls={false}\n className=\"number-editor\"\n onMouseDown={(e) => e.stopPropagation()}\n value={value as number}\n addonAfter=\"%\"\n onChange={onChange}\n />\n );\n};\n\nexport const getNumberEditor = (\n extraProps: Pick<\n InputNumberProps,\n 'max' | 'min' | 'addonBefore' | 'addonAfter' | 'precision'\n >,\n) => {\n const NumberEditor: SheetType.CellEditor = (props) => {\n const { value, onChange } = props;\n const inputNumberRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n inputNumberRef?.current?.focus();\n }, []);\n\n return (\n <AntInputNumber\n ref={inputNumberRef}\n {...extraProps}\n controls={false}\n className=\"number-editor\"\n onMouseDown={(e) => e.stopPropagation()}\n value={value as number}\n onChange={onChange}\n />\n );\n };\n\n return NumberEditor;\n};\n"],"mappings":";;;;;;AACA,SAASA,WAAW,IAAIC,cAAc,QAA0B,MAAM;AACtE,OAAO,sCAAsC;AAC7C,SAASC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC;AAAsB,SAAAC,GAAA,IAAAC,IAAA;AAEtB,OAAO,IAAMC,YAAkC,GAAG,SAArCA,YAAkCA,CAAIC,KAAK,EAAK;EAC3D,IAAQC,KAAK,GAAeD,KAAK,CAAzBC,KAAK;IAAEC,QAAQ,GAAKF,KAAK,CAAlBE,QAAQ;EACvB,IAAMC,cAAc,GAAGP,MAAM,CAAmB,IAAI,CAAC;EAErDD,SAAS,CAAC,YAAM;IAAA,IAAAS,qBAAA;IACdD,cAAc,aAAdA,cAAc,wBAAAC,qBAAA,GAAdD,cAAc,CAAEE,OAAO,cAAAD,qBAAA,uBAAvBA,qBAAA,CAAyBE,KAAK,CAAC,CAAC;EAClC,CAAC,EAAE,EAAE,CAAC;EAEN,oBACER,IAAA,CAACJ,cAAc;IACba,GAAG,EAAEJ,cAAe;IACpBK,QAAQ,EAAE,KAAM;IAChBC,SAAS,EAAC,eAAe;IACzBC,WAAW,EAAE,SAAAA,YAACC,CAAC;MAAA,OAAKA,CAAC,CAACC,eAAe,CAAC,CAAC;IAAA,CAAC;IACxCX,KAAK,EAAEA,KAAgB;IACvBY,UAAU,EAAC,GAAG;IACdX,QAAQ,EAAEA;EAAS,CACpB,CAAC;AAEN,CAAC;AAED,OAAO,IAAMY,eAAe,GAAG,SAAlBA,eAAeA,CAC1BC,UAGC,EACE;EACH,IAAMhB,YAAkC,GAAG,SAArCA,YAAkCA,CAAIC,KAAK,EAAK;IACpD,IAAQC,KAAK,GAAeD,KAAK,CAAzBC,KAAK;MAAEC,QAAQ,GAAKF,KAAK,CAAlBE,QAAQ;IACvB,IAAMC,cAAc,GAAGP,MAAM,CAAmB,IAAI,CAAC;IAErDD,SAAS,CAAC,YAAM;MAAA,IAAAqB,sBAAA;MACdb,cAAc,aAAdA,cAAc,wBAAAa,sBAAA,GAAdb,cAAc,CAAEE,OAAO,cAAAW,sBAAA,uBAAvBA,sBAAA,CAAyBV,KAAK,CAAC,CAAC;IAClC,CAAC,EAAE,EAAE,CAAC;IAEN,oBACER,IAAA,CAACJ,cAAc,EAAAuB,aAAA,CAAAA,aAAA;MACbV,GAAG,EAAEJ;IAAe,GAChBY,UAAU;MACdP,QAAQ,EAAE,KAAM;MAChBC,SAAS,EAAC,eAAe;MACzBC,WAAW,EAAE,SAAAA,YAACC,CAAC;QAAA,OAAKA,CAAC,CAACC,eAAe,CAAC,CAAC;MAAA,CAAC;MACxCX,KAAK,EAAEA,KAAgB;MACvBC,QAAQ,EAAEA;IAAS,EACpB,CAAC;EAEN,CAAC;EAED,OAAOH,YAAY;AACrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Select","jsx","_jsx","getSelectEditor","options","SelectEditor","props","value","onConfirm","handleChange","opt","updateValue","undefined","handleKeyDown","ev","which","persist","autoFocus","className","defaultOpen","allowClear","open","onMouseDown","e","stopPropagation","onChange","onKeyDown","popupClassName","checker","some","item","label"],"sources":["../../../../src/core/editor/selectEditor/index.tsx"],"sourcesContent":["import type { SheetType } from '@zhenliang/sheet/type';\nimport { Select } from 'antd';\nimport 'antd/es/select/style/index.css';\nimport './index.less';\n\nexport const getSelectEditor = (\n options: SheetType.Options[],\n): SheetType.CellEditor => {\n const SelectEditor: SheetType.CellEditor = (props) => {\n const { value, onConfirm } = props;\n\n const handleChange = (opt: any) => {\n const updateValue = opt === undefined ? null : opt;\n onConfirm(updateValue);\n };\n\n const handleKeyDown = (ev: any) => {\n // record last key pressed so we can handle enter\n if (ev.which === 13 || ev.which === 9) {\n ev.persist();\n }\n };\n\n return (\n <Select\n autoFocus\n className=\"select-editor\"\n defaultOpen\n allowClear\n open\n onMouseDown={(e) => {\n e.stopPropagation();\n }}\n value={value}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n options={options}\n popupClassName={'excelTablePopupClassName'}\n />\n );\n };\n\n SelectEditor.checker = (value) => {\n return (\n options.some((item: any) => item.value === value) ||\n options.some((item: any) => item.label === value)\n );\n };\n\n return SelectEditor;\n};\n\nexport default getSelectEditor;\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,MAAM;AAC7B,OAAO,gCAAgC;AACvC;AAAsB,SAAAC,GAAA,IAAAC,IAAA;AAEtB,OAAO,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,CAC1BC,OAA4B,EACH;EACzB,IAAMC,YAAkC,GAAG,SAArCA,YAAkCA,CAAIC,KAAK,EAAK;IACpD,IAAQC,KAAK,GAAgBD,KAAK,CAA1BC,KAAK;MAAEC,SAAS,GAAKF,KAAK,CAAnBE,SAAS;IAExB,IAAMC,YAAY,GAAG,SAAfA,YAAYA,CAAIC,GAAQ,EAAK;MACjC,IAAMC,WAAW,GAAGD,GAAG,KAAKE,SAAS,GAAG,IAAI,GAAGF,GAAG;MAClDF,SAAS,CAACG,WAAW,CAAC;IACxB,CAAC;IAED,IAAME,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,EAAO,EAAK;MACjC;MACA,IAAIA,EAAE,CAACC,KAAK,KAAK,EAAE,IAAID,EAAE,CAACC,KAAK,KAAK,CAAC,EAAE;QACrCD,EAAE,CAACE,OAAO,CAAC,CAAC;MACd;IACF,CAAC;IAED,oBACEd,IAAA,CAACF,MAAM;MACLiB,SAAS;MACTC,SAAS,EAAC,eAAe;MACzBC,WAAW;MACXC,UAAU;MACVC,IAAI;MACJC,WAAW,EAAE,SAAAA,YAACC,CAAC,EAAK;QAClBA,CAAC,CAACC,eAAe,CAAC,CAAC;MACrB,CAAE;MACFjB,KAAK,EAAEA,KAAM;MACbkB,QAAQ,EAAEhB,YAAa;MACvBiB,SAAS,EAAEb,aAAc;MACzBT,OAAO,EAAEA,OAAQ;MACjBuB,cAAc,EAAE;IAA2B,CAC5C,CAAC;EAEN,CAAC;EAEDtB,YAAY,CAACuB,OAAO,GAAG,UAACrB,KAAK,EAAK;IAChC,OACEH,OAAO,CAACyB,IAAI,CAAC,UAACC,IAAS;MAAA,OAAKA,IAAI,CAACvB,KAAK,KAAKA,KAAK;IAAA,EAAC,IACjDH,OAAO,CAACyB,IAAI,CAAC,UAACC,IAAS;MAAA,OAAKA,IAAI,CAACC,KAAK,KAAKxB,KAAK;IAAA,EAAC;EAErD,CAAC;EAED,OAAOF,YAAY;AACrB,CAAC;AAED,eAAeF,eAAe"}
|