@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.
- package/changes.md +45 -0
- package/package.json +1 -1
- package/dist/core/config.d.ts +0 -13
- package/dist/core/config.js +0 -13
- package/dist/core/editor/cascaderEditor/index.d.ts +0 -5
- package/dist/core/editor/cascaderEditor/index.js +0 -54
- package/dist/core/editor/cascaderEditor/index.less +0 -28
- package/dist/core/editor/dateEditor/index.d.ts +0 -5
- package/dist/core/editor/dateEditor/index.js +0 -55
- package/dist/core/editor/dateEditor/index.less +0 -11
- package/dist/core/editor/index.d.ts +0 -4
- package/dist/core/editor/index.js +0 -4
- package/dist/core/editor/numberEditor/index.d.ts +0 -8
- package/dist/core/editor/numberEditor/index.js +0 -107
- package/dist/core/editor/numberEditor/index.less +0 -30
- package/dist/core/editor/selectEditor/index.d.ts +0 -6
- package/dist/core/editor/selectEditor/index.js +0 -96
- package/dist/core/editor/selectEditor/index.less +0 -43
- package/dist/core/reducers/index.d.ts +0 -9
- package/dist/core/reducers/index.js +0 -38
- package/dist/core/reducers/keyboardReducer.d.ts +0 -2
- package/dist/core/reducers/keyboardReducer.js +0 -93
- package/dist/core/reducers/mouseReducer.d.ts +0 -2
- package/dist/core/reducers/mouseReducer.js +0 -164
- package/dist/core/reducers/sideEffectReducer.d.ts +0 -4
- package/dist/core/reducers/sideEffectReducer.js +0 -376
- package/dist/core/reducers/stateReducer.d.ts +0 -2
- package/dist/core/reducers/stateReducer.js +0 -174
- package/dist/core/sheet/Cell.d.ts +0 -4
- package/dist/core/sheet/Cell.js +0 -181
- package/dist/core/sheet/DataEditor.d.ts +0 -3
- package/dist/core/sheet/DataEditor.js +0 -24
- package/dist/core/sheet/DefaultCell.d.ts +0 -11
- package/dist/core/sheet/DefaultCell.js +0 -31
- package/dist/core/sheet/DefaultRow.d.ts +0 -12
- package/dist/core/sheet/DefaultRow.js +0 -28
- package/dist/core/sheet/DefaultRowMapper.d.ts +0 -8
- package/dist/core/sheet/DefaultRowMapper.js +0 -15
- package/dist/core/sheet/DefaultShell.d.ts +0 -8
- package/dist/core/sheet/DefaultShell.js +0 -12
- package/dist/core/sheet/Event.d.ts +0 -5
- package/dist/core/sheet/Event.js +0 -17
- package/dist/core/sheet/ValueViewer.d.ts +0 -3
- package/dist/core/sheet/ValueViewer.js +0 -9
- package/dist/core/sheet/index.d.ts +0 -5
- package/dist/core/sheet/index.js +0 -265
- package/dist/core/sheet/index.less +0 -307
- package/dist/core/sheet/useCellEvent.d.ts +0 -3
- package/dist/core/sheet/useCellEvent.js +0 -22
- package/dist/core/sheet/useContextMenu.d.ts +0 -21
- package/dist/core/sheet/useContextMenu.js +0 -86
- package/dist/core/sheet/useKeyBoardEvent.d.ts +0 -3
- package/dist/core/sheet/useKeyBoardEvent.js +0 -66
- package/dist/core/sheet/useMouseEvent.d.ts +0 -3
- package/dist/core/sheet/useMouseEvent.js +0 -298
- package/dist/core/sheet/useSelectVisible.d.ts +0 -2
- package/dist/core/sheet/useSelectVisible.js +0 -57
- package/dist/core/sheet/useVirtualList.d.ts +0 -7
- package/dist/core/sheet/useVirtualList.js +0 -103
- package/dist/core/sheet/var.less +0 -41
- package/dist/core/shell/draggableShell/index.d.ts +0 -5
- package/dist/core/shell/draggableShell/index.js +0 -197
- package/dist/core/shell/draggableShell/index.less +0 -16
- package/dist/core/shell/tableShell.d.ts +0 -5
- package/dist/core/shell/tableShell.js +0 -109
- package/dist/core/table/events.d.ts +0 -15
- package/dist/core/table/events.js +0 -95
- package/dist/core/table/index.d.ts +0 -4
- package/dist/core/table/index.js +0 -313
- package/dist/core/table/useGroupConfig.d.ts +0 -2
- package/dist/core/table/useGroupConfig.js +0 -65
- package/dist/core/table/useRowSelection.d.ts +0 -2
- package/dist/core/table/useRowSelection.js +0 -24
- package/dist/core/table/util.d.ts +0 -8
- package/dist/core/table/util.js +0 -29
- package/dist/core/util.d.ts +0 -59
- package/dist/core/util.js +0 -490
- package/dist/core/viewer/btnViewer/index.d.ts +0 -2
- package/dist/core/viewer/btnViewer/index.js +0 -37
- package/dist/core/viewer/cascaderViewer/index.d.ts +0 -2
- package/dist/core/viewer/cascaderViewer/index.js +0 -11
- package/dist/core/viewer/checkViewer/index.d.ts +0 -2
- package/dist/core/viewer/checkViewer/index.js +0 -23
- package/dist/core/viewer/editViewer/index.d.ts +0 -2
- package/dist/core/viewer/editViewer/index.js +0 -31
- package/dist/core/viewer/groupViewer/index.d.ts +0 -2
- package/dist/core/viewer/groupViewer/index.js +0 -34
- package/dist/core/viewer/index.d.ts +0 -7
- package/dist/core/viewer/index.js +0 -7
- package/dist/core/viewer/selectorViewer/index.d.ts +0 -2
- package/dist/core/viewer/selectorViewer/index.js +0 -16
- package/dist/core/viewer/switchViewer/index.d.ts +0 -2
- package/dist/core/viewer/switchViewer/index.js +0 -22
- package/dist/example/antComponent.d.ts +0 -3
- package/dist/example/antComponent.js +0 -314
- package/dist/example/basic.d.ts +0 -4
- package/dist/example/basic.js +0 -121
- package/dist/example/ellipsis.d.ts +0 -3
- package/dist/example/ellipsis.js +0 -64
- package/dist/example/fixed.d.ts +0 -3
- package/dist/example/fixed.js +0 -89
- package/dist/example/group.d.ts +0 -3
- package/dist/example/group.js +0 -123
- package/dist/example/index.less +0 -5
- package/dist/example/selection.d.ts +0 -4
- package/dist/example/selection.js +0 -86
- package/dist/example/sheet.d.ts +0 -4
- package/dist/example/sheet.js +0 -393
- package/dist/example/valuationAnalyze.d.ts +0 -2
- package/dist/example/valuationAnalyze.js +0 -227
- package/dist/hooks/index.d.ts +0 -8
- package/dist/hooks/index.js +0 -7
- package/dist/hooks/useEventBus.d.ts +0 -3
- package/dist/hooks/useEventBus.js +0 -17
- package/dist/hooks/useKeyboard.d.ts +0 -18
- package/dist/hooks/useKeyboard.js +0 -108
- package/dist/hooks/useMiddlewareReducer.d.ts +0 -12
- package/dist/hooks/useMiddlewareReducer.js +0 -47
- package/dist/hooks/useMouse.d.ts +0 -11
- package/dist/hooks/useMouse.js +0 -68
- package/dist/hooks/useSetState.d.ts +0 -2
- package/dist/hooks/useSetState.js +0 -27
- package/dist/hooks/useSheetEvent.d.ts +0 -5
- package/dist/hooks/useSheetEvent.js +0 -5
- package/dist/hooks/useWidthConfig.d.ts +0 -4
- package/dist/hooks/useWidthConfig.js +0 -5
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/standardUtils/index.d.ts +0 -9
- package/dist/standardUtils/index.js +0 -32
- package/dist/type/index.d.ts +0 -2
- package/dist/type/index.js +0 -4
- package/dist/type/sheet.d.ts +0 -205
- package/dist/type/sheet.js +0 -9
- package/dist/type/sheetTable.d.ts +0 -89
- package/dist/type/sheetTable.js +0 -1
- package/dist/typings/index.d.ts +0 -1
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { SheetType } from "../../../type";
|
|
2
|
-
import './index.less';
|
|
3
|
-
export declare const DraggableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
|
|
4
|
-
children: React.ReactElement;
|
|
5
|
-
}>;
|
|
@@ -1,197 +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 _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; }
|
|
3
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
|
-
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); }
|
|
5
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
-
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."); }
|
|
7
|
-
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); }
|
|
8
|
-
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; }
|
|
9
|
-
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; } }
|
|
10
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
-
import { createElement, useEffect, useMemo, useRef } from 'react';
|
|
12
|
-
import { useSetState, useWidth } from "../../../hooks";
|
|
13
|
-
import { classNames } from "../../util";
|
|
14
|
-
import { CheckViewer } from "../../viewer/checkViewer";
|
|
15
|
-
import { GroupViewer } from "../../viewer/groupViewer";
|
|
16
|
-
import "./index.less";
|
|
17
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
20
|
-
export var DraggableShell = function DraggableShell(_ref) {
|
|
21
|
-
var columns = _ref.columns,
|
|
22
|
-
className = _ref.className,
|
|
23
|
-
showGroup = _ref.showGroup,
|
|
24
|
-
showSelect = _ref.showSelect,
|
|
25
|
-
controlProps = _ref.controlProps,
|
|
26
|
-
_ref$controlWidth = _ref.controlWidth,
|
|
27
|
-
controlWidth = _ref$controlWidth === void 0 ? 30 : _ref$controlWidth;
|
|
28
|
-
var TableShell = function TableShell(_ref2) {
|
|
29
|
-
var children = _ref2.children;
|
|
30
|
-
var headRef = useRef(null);
|
|
31
|
-
var downRef = useRef(null);
|
|
32
|
-
var _useSetState = useSetState({}),
|
|
33
|
-
_useSetState2 = _slicedToArray(_useSetState, 2),
|
|
34
|
-
_widths = _useSetState2[0],
|
|
35
|
-
_setWidth = _useSetState2[1];
|
|
36
|
-
var _useWidth = useWidth(),
|
|
37
|
-
contextWidths = _useWidth.widths,
|
|
38
|
-
contextSetWidth = _useWidth.onChange;
|
|
39
|
-
var setWidth = contextSetWidth || _setWidth;
|
|
40
|
-
var widths = contextWidths || _widths;
|
|
41
|
-
var hasControl = showGroup || showSelect;
|
|
42
|
-
var thItems = useMemo(function () {
|
|
43
|
-
var ths = [];
|
|
44
|
-
if (hasControl) {
|
|
45
|
-
var _controlProps$group, _controlProps$check, _controlProps$check2, _controlProps$check3;
|
|
46
|
-
ths.push( /*#__PURE__*/_jsxs("th", {
|
|
47
|
-
className: "cell cell-title read-only sheet-control",
|
|
48
|
-
children: [showGroup && /*#__PURE__*/_jsx(GroupViewer, {
|
|
49
|
-
row: -1,
|
|
50
|
-
col: -1,
|
|
51
|
-
value: true,
|
|
52
|
-
record: {
|
|
53
|
-
open: controlProps === null || controlProps === void 0 ? void 0 : (_controlProps$group = controlProps.group) === null || _controlProps$group === void 0 ? void 0 : _controlProps$group.open,
|
|
54
|
-
isHeader: true
|
|
55
|
-
}
|
|
56
|
-
}), showSelect && /*#__PURE__*/_jsx(CheckViewer, {
|
|
57
|
-
row: -1,
|
|
58
|
-
col: -1,
|
|
59
|
-
value: controlProps === null || controlProps === void 0 ? void 0 : (_controlProps$check = controlProps.check) === null || _controlProps$check === void 0 ? void 0 : _controlProps$check.checked,
|
|
60
|
-
record: {
|
|
61
|
-
open: controlProps === null || controlProps === void 0 ? void 0 : (_controlProps$check2 = controlProps.check) === null || _controlProps$check2 === void 0 ? void 0 : _controlProps$check2.checked,
|
|
62
|
-
isHeader: true,
|
|
63
|
-
indeterminate: controlProps === null || controlProps === void 0 ? void 0 : (_controlProps$check3 = controlProps.check) === null || _controlProps$check3 === void 0 ? void 0 : _controlProps$check3.indeterminate
|
|
64
|
-
}
|
|
65
|
-
})]
|
|
66
|
-
}, "-1"));
|
|
67
|
-
}
|
|
68
|
-
columns.forEach(function (item, index) {
|
|
69
|
-
var _item$titleConfig, _item$titleConfig2, _item$titleConfig3, _item$dataIndex, _ref3;
|
|
70
|
-
((_item$titleConfig = item.titleConfig) === null || _item$titleConfig === void 0 ? void 0 : _item$titleConfig.colSpan) !== 0 && ths.push( /*#__PURE__*/_jsx("th", {
|
|
71
|
-
className: classNames('cell', 'cell-title', 'read-only', item.fixed && 'fixed', item.fixed && "fixed-".concat(item.fixed), (_item$titleConfig2 = item.titleConfig) === null || _item$titleConfig2 === void 0 ? void 0 : _item$titleConfig2.className),
|
|
72
|
-
colSpan: (_item$titleConfig3 = item.titleConfig) === null || _item$titleConfig3 === void 0 ? void 0 : _item$titleConfig3.colSpan,
|
|
73
|
-
style: {
|
|
74
|
-
textAlign: (_ref3 = item.align) !== null && _ref3 !== void 0 ? _ref3 : 'unset',
|
|
75
|
-
left: item.fixed === 'left' ? 0 : 'unset',
|
|
76
|
-
right: item.fixed === 'right' ? 0 : 'unset'
|
|
77
|
-
},
|
|
78
|
-
onMouseDown: function onMouseDown(e) {
|
|
79
|
-
var target = e.target;
|
|
80
|
-
downRef.current = target;
|
|
81
|
-
if (e.nativeEvent.offsetX > target.offsetWidth - 10) {
|
|
82
|
-
downRef.current.mouseDown = true;
|
|
83
|
-
downRef.current.oldX = e.nativeEvent.x;
|
|
84
|
-
downRef.current.oldWidth = downRef.current.offsetWidth;
|
|
85
|
-
} else {
|
|
86
|
-
downRef.current = null;
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
onMouseMove: function onMouseMove(e) {
|
|
90
|
-
var target = e.target;
|
|
91
|
-
if (e.nativeEvent.offsetX > target.offsetWidth - 8) {
|
|
92
|
-
target.style.cursor = 'col-resize';
|
|
93
|
-
} else {
|
|
94
|
-
target.style.cursor = 'default';
|
|
95
|
-
}
|
|
96
|
-
//取出暂存的Table Cell
|
|
97
|
-
if (downRef.current === undefined) downRef.current = target;
|
|
98
|
-
//调整宽度
|
|
99
|
-
},
|
|
100
|
-
children: /*#__PURE__*/_jsx("span", {
|
|
101
|
-
className: "value-viewer",
|
|
102
|
-
children: typeof item.title === 'function' ? /*#__PURE__*/createElement(item.title) : item.title
|
|
103
|
-
})
|
|
104
|
-
}, (_item$dataIndex = item.dataIndex) !== null && _item$dataIndex !== void 0 ? _item$dataIndex : index));
|
|
105
|
-
});
|
|
106
|
-
return ths;
|
|
107
|
-
}, [columns]);
|
|
108
|
-
var colItems = useMemo(function () {
|
|
109
|
-
var cols = [];
|
|
110
|
-
if (hasControl) {
|
|
111
|
-
cols.push( /*#__PURE__*/_jsx("col", {
|
|
112
|
-
className: classNames('sheet-control'),
|
|
113
|
-
style: {
|
|
114
|
-
width: controlWidth
|
|
115
|
-
}
|
|
116
|
-
}, "sheet-control"));
|
|
117
|
-
}
|
|
118
|
-
var i = 0;
|
|
119
|
-
columns.forEach(function (item, index) {
|
|
120
|
-
var _item$titleConfig4, _item$dataIndex2;
|
|
121
|
-
var currentWidth = item.width || 'unset';
|
|
122
|
-
if (((_item$titleConfig4 = item.titleConfig) === null || _item$titleConfig4 === void 0 ? void 0 : _item$titleConfig4.colSpan) !== 0) {
|
|
123
|
-
currentWidth = widths[i] || item.width || 'unset';
|
|
124
|
-
i++;
|
|
125
|
-
}
|
|
126
|
-
cols.push( /*#__PURE__*/_jsx("col", {
|
|
127
|
-
className: classNames('cell'),
|
|
128
|
-
style: {
|
|
129
|
-
width: currentWidth
|
|
130
|
-
}
|
|
131
|
-
}, (_item$dataIndex2 = item.dataIndex) !== null && _item$dataIndex2 !== void 0 ? _item$dataIndex2 : index));
|
|
132
|
-
});
|
|
133
|
-
return cols;
|
|
134
|
-
}, [widths, hasControl, columns]);
|
|
135
|
-
useEffect(function () {
|
|
136
|
-
var handleMouseUp = function handleMouseUp() {
|
|
137
|
-
//结束宽度调整
|
|
138
|
-
if (downRef.current) {
|
|
139
|
-
downRef.current.mouseDown = false;
|
|
140
|
-
downRef.current.style.cursor = 'default';
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
var handleMouseMove = function handleMouseMove(e) {
|
|
144
|
-
var _downRef$current, _downRef$current2;
|
|
145
|
-
if (!downRef.current || !downRef.current.mouseDown) return;
|
|
146
|
-
if (((_downRef$current = downRef.current) === null || _downRef$current === void 0 ? void 0 : _downRef$current.mouseDown) !== null && ((_downRef$current2 = downRef.current) === null || _downRef$current2 === void 0 ? void 0 : _downRef$current2.mouseDown) === true) {
|
|
147
|
-
var _downRef$current$oldW, _downRef$current$oldX;
|
|
148
|
-
downRef.current.style.cursor = 'default';
|
|
149
|
-
if (((_downRef$current$oldW = downRef.current.oldWidth) !== null && _downRef$current$oldW !== void 0 ? _downRef$current$oldW : 0) + (e.x - ((_downRef$current$oldX = downRef.current.oldX) !== null && _downRef$current$oldX !== void 0 ? _downRef$current$oldX : 0)) > 0) {
|
|
150
|
-
var _downRef$current$oldW2, _downRef$current$oldX2, _headRef$current;
|
|
151
|
-
var newWidth = Math.max(Number(((_downRef$current$oldW2 = downRef.current.oldWidth) !== null && _downRef$current$oldW2 !== void 0 ? _downRef$current$oldW2 : 0) + (e.x - ((_downRef$current$oldX2 = downRef.current.oldX) !== null && _downRef$current$oldX2 !== void 0 ? _downRef$current$oldX2 : 0))), 50);
|
|
152
|
-
var cellList = [].slice.call((_headRef$current = headRef.current) === null || _headRef$current === void 0 ? void 0 : _headRef$current.cells);
|
|
153
|
-
var changeIndex = cellList.indexOf(downRef.current);
|
|
154
|
-
//调整该列中的每个Cell
|
|
155
|
-
var _widths2 = _defineProperty({
|
|
156
|
-
length: columns.length
|
|
157
|
-
}, hasControl ? changeIndex - 1 : changeIndex, newWidth);
|
|
158
|
-
setWidth(_widths2);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
document.addEventListener('mouseup', handleMouseUp);
|
|
163
|
-
document.addEventListener('mousemove', handleMouseMove);
|
|
164
|
-
return function () {
|
|
165
|
-
document.removeEventListener('mouseup', handleMouseUp);
|
|
166
|
-
document.removeEventListener('mousemove', handleMouseMove);
|
|
167
|
-
};
|
|
168
|
-
}, [hasControl]);
|
|
169
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
170
|
-
children: [/*#__PURE__*/_jsxs("table", {
|
|
171
|
-
className: classNames('header', 'harvest-sheet', className),
|
|
172
|
-
style: {
|
|
173
|
-
position: 'sticky',
|
|
174
|
-
top: 0,
|
|
175
|
-
zIndex: 3
|
|
176
|
-
},
|
|
177
|
-
children: [/*#__PURE__*/_jsx("colgroup", {
|
|
178
|
-
children: colItems
|
|
179
|
-
}), /*#__PURE__*/_jsx("thead", {
|
|
180
|
-
children: /*#__PURE__*/_jsx("tr", {
|
|
181
|
-
ref: headRef,
|
|
182
|
-
children: thItems
|
|
183
|
-
})
|
|
184
|
-
})]
|
|
185
|
-
}, "header"), /*#__PURE__*/_jsxs("table", {
|
|
186
|
-
className: classNames('body', 'harvest-sheet'),
|
|
187
|
-
children: [/*#__PURE__*/_jsx("colgroup", {
|
|
188
|
-
className: "header",
|
|
189
|
-
children: colItems
|
|
190
|
-
}), /*#__PURE__*/_jsx("tbody", {
|
|
191
|
-
children: children
|
|
192
|
-
}, "tbody")]
|
|
193
|
-
}, "body")]
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
return TableShell;
|
|
197
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { SheetType } from "../../type";
|
|
2
|
-
import './draggableShell/index.less';
|
|
3
|
-
export declare const TableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
|
|
4
|
-
children: React.ReactElement;
|
|
5
|
-
}>;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { classNames } from "../util";
|
|
3
|
-
import { CheckViewer } from "../viewer/checkViewer";
|
|
4
|
-
import { GroupViewer } from "../viewer/groupViewer";
|
|
5
|
-
import "./draggableShell/index.less";
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
|
-
export var TableShell = function TableShell(_ref) {
|
|
10
|
-
var columns = _ref.columns,
|
|
11
|
-
className = _ref.className,
|
|
12
|
-
showGroup = _ref.showGroup,
|
|
13
|
-
showSelect = _ref.showSelect,
|
|
14
|
-
controlProps = _ref.controlProps,
|
|
15
|
-
_ref$controlWidth = _ref.controlWidth,
|
|
16
|
-
controlWidth = _ref$controlWidth === void 0 ? 30 : _ref$controlWidth;
|
|
17
|
-
var TableShell = function TableShell(_ref2) {
|
|
18
|
-
var children = _ref2.children;
|
|
19
|
-
var thItems = useMemo(function () {
|
|
20
|
-
var ths = [];
|
|
21
|
-
if (showGroup || showSelect) {
|
|
22
|
-
var _controlProps$group, _controlProps$check, _controlProps$check2, _controlProps$check3;
|
|
23
|
-
ths.push( /*#__PURE__*/_jsxs("th", {
|
|
24
|
-
className: "cell cell-title read-only sheet-control",
|
|
25
|
-
children: [showGroup && /*#__PURE__*/_jsx(GroupViewer, {
|
|
26
|
-
row: -1,
|
|
27
|
-
col: -1,
|
|
28
|
-
value: true,
|
|
29
|
-
record: {
|
|
30
|
-
open: controlProps === null || controlProps === void 0 ? void 0 : (_controlProps$group = controlProps.group) === null || _controlProps$group === void 0 ? void 0 : _controlProps$group.open,
|
|
31
|
-
isHeader: true
|
|
32
|
-
}
|
|
33
|
-
}), showSelect && /*#__PURE__*/_jsx(CheckViewer, {
|
|
34
|
-
row: -1,
|
|
35
|
-
col: -1,
|
|
36
|
-
value: controlProps === null || controlProps === void 0 ? void 0 : (_controlProps$check = controlProps.check) === null || _controlProps$check === void 0 ? void 0 : _controlProps$check.checked,
|
|
37
|
-
record: {
|
|
38
|
-
open: controlProps === null || controlProps === void 0 ? void 0 : (_controlProps$check2 = controlProps.check) === null || _controlProps$check2 === void 0 ? void 0 : _controlProps$check2.checked,
|
|
39
|
-
isHeader: true,
|
|
40
|
-
indeterminate: controlProps === null || controlProps === void 0 ? void 0 : (_controlProps$check3 = controlProps.check) === null || _controlProps$check3 === void 0 ? void 0 : _controlProps$check3.indeterminate
|
|
41
|
-
}
|
|
42
|
-
})]
|
|
43
|
-
}, "-1"));
|
|
44
|
-
}
|
|
45
|
-
columns.forEach(function (item, index) {
|
|
46
|
-
var _item$titleConfig, _item$titleConfig2, _ref3;
|
|
47
|
-
((_item$titleConfig = item.titleConfig) === null || _item$titleConfig === void 0 ? void 0 : _item$titleConfig.colSpan) !== 0 && ths.push( /*#__PURE__*/_jsx("th", {
|
|
48
|
-
className: classNames('cell', 'cell-title', 'read-only', item.fixed && 'fixed', item.fixed && "fixed-".concat(item.fixed)),
|
|
49
|
-
colSpan: (_item$titleConfig2 = item.titleConfig) === null || _item$titleConfig2 === void 0 ? void 0 : _item$titleConfig2.colSpan,
|
|
50
|
-
style: {
|
|
51
|
-
textAlign: (_ref3 = item.align) !== null && _ref3 !== void 0 ? _ref3 : 'unset',
|
|
52
|
-
left: item.fixed === 'left' ? 0 : 'unset',
|
|
53
|
-
right: item.fixed === 'right' ? 0 : 'unset'
|
|
54
|
-
},
|
|
55
|
-
children: /*#__PURE__*/_jsx("span", {
|
|
56
|
-
className: "value-viewer",
|
|
57
|
-
children: item.title
|
|
58
|
-
})
|
|
59
|
-
}, item.dataIndex || index));
|
|
60
|
-
});
|
|
61
|
-
return ths;
|
|
62
|
-
}, [columns, showGroup || showSelect, controlProps]);
|
|
63
|
-
var colItems = useMemo(function () {
|
|
64
|
-
var cols = [];
|
|
65
|
-
if (showGroup || showSelect) {
|
|
66
|
-
cols.push( /*#__PURE__*/_jsx("col", {
|
|
67
|
-
className: classNames('sheet-control'),
|
|
68
|
-
style: {
|
|
69
|
-
width: controlWidth
|
|
70
|
-
}
|
|
71
|
-
}, "sheet-control"));
|
|
72
|
-
}
|
|
73
|
-
columns.forEach(function (item, index) {
|
|
74
|
-
cols.push( /*#__PURE__*/_jsx("col", {
|
|
75
|
-
className: classNames('cell'),
|
|
76
|
-
style: {
|
|
77
|
-
width: item.width || 'unset'
|
|
78
|
-
}
|
|
79
|
-
}, item.dataIndex || index));
|
|
80
|
-
});
|
|
81
|
-
return cols;
|
|
82
|
-
}, [columns, showGroup || showSelect, controlWidth]);
|
|
83
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
84
|
-
children: [/*#__PURE__*/_jsxs("table", {
|
|
85
|
-
className: classNames('header', 'harvest-sheet', className),
|
|
86
|
-
style: {
|
|
87
|
-
position: 'sticky',
|
|
88
|
-
top: 0,
|
|
89
|
-
zIndex: 3
|
|
90
|
-
},
|
|
91
|
-
children: [/*#__PURE__*/_jsx("colgroup", {
|
|
92
|
-
children: colItems
|
|
93
|
-
}), /*#__PURE__*/_jsx("thead", {
|
|
94
|
-
children: /*#__PURE__*/_jsx("tr", {
|
|
95
|
-
children: thItems
|
|
96
|
-
})
|
|
97
|
-
})]
|
|
98
|
-
}, "header"), /*#__PURE__*/_jsxs("table", {
|
|
99
|
-
className: classNames('body', 'harvest-sheet'),
|
|
100
|
-
children: [/*#__PURE__*/_jsx("colgroup", {
|
|
101
|
-
children: colItems
|
|
102
|
-
}), /*#__PURE__*/_jsx("tbody", {
|
|
103
|
-
children: children
|
|
104
|
-
}, "tbody")]
|
|
105
|
-
}, "body")]
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
return TableShell;
|
|
109
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { SheetTableType, SheetType } from "../../type";
|
|
2
|
-
import { FC } from 'react';
|
|
3
|
-
export declare const SelectionEvent: FC<{
|
|
4
|
-
hasChildren: boolean;
|
|
5
|
-
rowSelection?: SheetTableType.TableRowSelection;
|
|
6
|
-
onChange: (value: unknown) => void;
|
|
7
|
-
}>;
|
|
8
|
-
export declare const GroupEvent: FC<{
|
|
9
|
-
hasChildren: boolean;
|
|
10
|
-
rowGroupConfig: SheetType.RowGroupConfig;
|
|
11
|
-
data: SheetType.Cell[][];
|
|
12
|
-
sheetInstance: SheetType.SheetInstance | null;
|
|
13
|
-
onGroupChange: (value: SheetType.RowGroupConfig) => void;
|
|
14
|
-
onGridChange: (value: SheetType.Cell[][]) => void;
|
|
15
|
-
}>;
|
|
@@ -1,95 +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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
-
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; }
|
|
13
|
-
import { SheetEvent } from "../sheet/Event";
|
|
14
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
-
export var SelectionEvent = function SelectionEvent(props) {
|
|
18
|
-
var hasChildren = props.hasChildren,
|
|
19
|
-
rowSelection = props.rowSelection,
|
|
20
|
-
onChange = props.onChange;
|
|
21
|
-
if (hasChildren || !rowSelection) return null;
|
|
22
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
23
|
-
children: [/*#__PURE__*/_jsx(SheetEvent, {
|
|
24
|
-
name: "row-select",
|
|
25
|
-
handler: onChange
|
|
26
|
-
}, "row-select"), /*#__PURE__*/_jsx(SheetEvent, {
|
|
27
|
-
name: "row-select-title",
|
|
28
|
-
handler: onChange
|
|
29
|
-
}, "row-select-title"), ","]
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
export var GroupEvent = function GroupEvent(props) {
|
|
33
|
-
var hasChildren = props.hasChildren,
|
|
34
|
-
rowGroupConfig = props.rowGroupConfig,
|
|
35
|
-
data = props.data,
|
|
36
|
-
sheetInstance = props.sheetInstance,
|
|
37
|
-
onGroupChange = props.onGroupChange,
|
|
38
|
-
onGridChange = props.onGridChange;
|
|
39
|
-
if (!hasChildren) return null;
|
|
40
|
-
var _ref = rowGroupConfig || {},
|
|
41
|
-
groups = _ref.groups;
|
|
42
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
43
|
-
children: [/*#__PURE__*/_jsx(SheetEvent, {
|
|
44
|
-
name: "group-open",
|
|
45
|
-
handler: function handler(e) {
|
|
46
|
-
var _ref2 = e,
|
|
47
|
-
row = _ref2.row;
|
|
48
|
-
var index = groups.findIndex(function (item) {
|
|
49
|
-
return item.groupStart === row;
|
|
50
|
-
});
|
|
51
|
-
if (index >= 0) {
|
|
52
|
-
var groupOpen = _toConsumableArray(rowGroupConfig.groupOpen);
|
|
53
|
-
groupOpen[index] = !rowGroupConfig.groupOpen[index];
|
|
54
|
-
onGroupChange && onGroupChange(_objectSpread(_objectSpread({}, rowGroupConfig), {}, {
|
|
55
|
-
groupOpen: groupOpen
|
|
56
|
-
}));
|
|
57
|
-
var newGrid = _toConsumableArray(data);
|
|
58
|
-
newGrid[row] = _toConsumableArray(newGrid[row]);
|
|
59
|
-
newGrid[row][0] = _objectSpread(_objectSpread({}, newGrid[row][0]), {}, {
|
|
60
|
-
record: {
|
|
61
|
-
open: !!groupOpen[index]
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
onGridChange && onGridChange(newGrid);
|
|
65
|
-
sheetInstance === null || sheetInstance === void 0 ? void 0 : sheetInstance.pushToHistory({
|
|
66
|
-
type: 'Custom',
|
|
67
|
-
changes: [],
|
|
68
|
-
extraInfo: {
|
|
69
|
-
extraType: 'group',
|
|
70
|
-
groupConfig: rowGroupConfig,
|
|
71
|
-
data: data
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}, "group-open"), /*#__PURE__*/_jsx(SheetEvent, {
|
|
77
|
-
name: "group-open-title",
|
|
78
|
-
handler: function handler(value) {
|
|
79
|
-
onGroupChange && onGroupChange(_objectSpread(_objectSpread({}, rowGroupConfig), {}, {
|
|
80
|
-
groupOpen: Array(rowGroupConfig === null || rowGroupConfig === void 0 ? void 0 : rowGroupConfig.groupOpen.length).fill(value),
|
|
81
|
-
defaultOpen: !groups.length ? value : undefined
|
|
82
|
-
}));
|
|
83
|
-
sheetInstance === null || sheetInstance === void 0 ? void 0 : sheetInstance.pushToHistory({
|
|
84
|
-
type: 'Custom',
|
|
85
|
-
changes: [],
|
|
86
|
-
extraInfo: {
|
|
87
|
-
extraType: 'group',
|
|
88
|
-
groupConfig: rowGroupConfig,
|
|
89
|
-
data: data
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}, "group-open-title")]
|
|
94
|
-
});
|
|
95
|
-
};
|