@arim-aisdc/public-components 0.0.1
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/Foo/index.js +9 -0
- package/dist/Foo/index.less +3 -0
- package/dist/TableMax/TableBody/Row.js +231 -0
- package/dist/TableMax/TableBody/index.js +249 -0
- package/dist/TableMax/TableBody/index.less +141 -0
- package/dist/TableMax/TableHeader/Cell.js +125 -0
- package/dist/TableMax/TableHeader/index.js +121 -0
- package/dist/TableMax/TableHeader/index.less +212 -0
- package/dist/TableMax/TableHeader/utils.js +55 -0
- package/dist/TableMax/components/ColumnEdit/index.js +87 -0
- package/dist/TableMax/components/ColumnEdit/index.less +27 -0
- package/dist/TableMax/components/ColumnFilter/FilterDateRange/index.js +86 -0
- package/dist/TableMax/components/ColumnFilter/FilterDateRange/index.less +58 -0
- package/dist/TableMax/components/ColumnFilter/MultipleSelect/index.js +51 -0
- package/dist/TableMax/components/ColumnFilter/MultipleSelect/index.less +23 -0
- package/dist/TableMax/components/ColumnFilter/SingleSelect/index.js +26 -0
- package/dist/TableMax/components/ColumnFilter/SingleSelect/index.less +5 -0
- package/dist/TableMax/components/ColumnFilter/customFilterFns.js +17 -0
- package/dist/TableMax/components/ColumnFilter/index.js +215 -0
- package/dist/TableMax/components/ColumnSetting/index.js +334 -0
- package/dist/TableMax/components/ColumnSetting/index.less +147 -0
- package/dist/TableMax/components/CustomDragerLayer/index.js +165 -0
- package/dist/TableMax/components/FilterDateRange/index.js +75 -0
- package/dist/TableMax/components/FilterDateRange/index.less +70 -0
- package/dist/TableMax/components/PaginationMax/index.js +111 -0
- package/dist/TableMax/components/PaginationMax/index.less +0 -0
- package/dist/TableMax/components/RowContent/index.js +225 -0
- package/dist/TableMax/components/RowContent/index.less +84 -0
- package/dist/TableMax/components/ScrollBar/index.js +49 -0
- package/dist/TableMax/components/ScrollBar/index.less +61 -0
- package/dist/TableMax/components/Selection/index.js +29 -0
- package/dist/TableMax/index.js +1162 -0
- package/dist/TableMax/index.less +223 -0
- package/dist/TableMax/type.d.ts +208 -0
- package/dist/TableMax/utils.js +33 -0
- package/dist/index.js +2 -0
- package/package.json +89 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) na.xu2278@foxmail.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#public-components
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
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(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
// import { layoutContext } from '@/layouts';
|
|
14
|
+
import { flexRender } from '@tanstack/react-table';
|
|
15
|
+
import { useEffect, useRef } from 'react';
|
|
16
|
+
import { useDrag, useDrop } from 'react-dnd';
|
|
17
|
+
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
18
|
+
import { EditableCell } from "../components/ColumnEdit";
|
|
19
|
+
import { getPinningStyle } from "../TableHeader/utils";
|
|
20
|
+
import "./index.less";
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
23
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
var Row = function Row(_ref) {
|
|
25
|
+
var _row, _row2;
|
|
26
|
+
var table = _ref.table,
|
|
27
|
+
tableId = _ref.tableId,
|
|
28
|
+
row = _ref.row,
|
|
29
|
+
rowSelectedId = _ref.rowSelectedId,
|
|
30
|
+
setRowSelectedId = _ref.setRowSelectedId,
|
|
31
|
+
selectedRowChange = _ref.selectedRowChange,
|
|
32
|
+
onSelectChange = _ref.onSelectChange,
|
|
33
|
+
canSelection = _ref.canSelection,
|
|
34
|
+
rowSelectionChange = _ref.rowSelectionChange,
|
|
35
|
+
reorderRow = _ref.reorderRow,
|
|
36
|
+
tableContainerWidth = _ref.tableContainerWidth,
|
|
37
|
+
canRowDrag = _ref.canRowDrag,
|
|
38
|
+
rowClassName = _ref.rowClassName,
|
|
39
|
+
cellClassName = _ref.cellClassName,
|
|
40
|
+
rowStyle = _ref.rowStyle,
|
|
41
|
+
getCellProps = _ref.getCellProps,
|
|
42
|
+
editting = _ref.editting,
|
|
43
|
+
edittingRowStatus = _ref.edittingRowStatus,
|
|
44
|
+
renderSubComponent = _ref.renderSubComponent,
|
|
45
|
+
selectedRowDragging = _ref.selectedRowDragging,
|
|
46
|
+
setSelectedRowDragging = _ref.setSelectedRowDragging,
|
|
47
|
+
onRowMouseEnter = _ref.onRowMouseEnter,
|
|
48
|
+
onRowMouseLeave = _ref.onRowMouseLeave,
|
|
49
|
+
onRowMouseClick = _ref.onRowMouseClick,
|
|
50
|
+
onRowMouseDoubleClick = _ref.onRowMouseDoubleClick,
|
|
51
|
+
rowHeight = _ref.rowHeight,
|
|
52
|
+
disableDragRowIds = _ref.disableDragRowIds,
|
|
53
|
+
selectRowWhenClick = _ref.selectRowWhenClick,
|
|
54
|
+
hasVerticalScrollBar = _ref.hasVerticalScrollBar;
|
|
55
|
+
// const { theme } = useContext(layoutContext);
|
|
56
|
+
var theme = 'light';
|
|
57
|
+
var timerRef = useRef();
|
|
58
|
+
var _useDrop = useDrop({
|
|
59
|
+
accept: 'TABLE_ROW',
|
|
60
|
+
drop: function drop(formDatas, monitor) {
|
|
61
|
+
console.log('drop================start-', monitor);
|
|
62
|
+
return reorderRow === null || reorderRow === void 0 ? void 0 : reorderRow(formDatas, {
|
|
63
|
+
hoverRow: row,
|
|
64
|
+
targetTableId: tableId
|
|
65
|
+
});
|
|
66
|
+
// return reorderRow?.(draggedRow, { ...row, tableId });
|
|
67
|
+
}
|
|
68
|
+
}),
|
|
69
|
+
_useDrop2 = _slicedToArray(_useDrop, 2),
|
|
70
|
+
dropRef = _useDrop2[1];
|
|
71
|
+
// const [centerSubRowHeight, setCenterSubRowHeight] = useState();
|
|
72
|
+
// const centerSubRowRef: any = useRef(null);
|
|
73
|
+
|
|
74
|
+
var _useDrag = useDrag({
|
|
75
|
+
collect: function collect(monitor) {
|
|
76
|
+
return {
|
|
77
|
+
isDragging: monitor.isDragging()
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
item: function item() {
|
|
81
|
+
var _table$getSelectedRow;
|
|
82
|
+
var selectedRows = ((_table$getSelectedRow = table.getSelectedRowModel()) === null || _table$getSelectedRow === void 0 ? void 0 : _table$getSelectedRow.rows) || [];
|
|
83
|
+
var selectedRowsNumber = (selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.length) || 0;
|
|
84
|
+
var selectedRowsIndexList = selectedRows === null || selectedRows === void 0 ? void 0 : selectedRows.map(function (row) {
|
|
85
|
+
return row.index;
|
|
86
|
+
});
|
|
87
|
+
var isMultipleDrag = selectedRowsNumber > 1 && selectedRowsIndexList.includes(row.index);
|
|
88
|
+
return {
|
|
89
|
+
draggedRow: row,
|
|
90
|
+
isMultipleDrag: isMultipleDrag,
|
|
91
|
+
draggedRows: isMultipleDrag ? selectedRows : [row],
|
|
92
|
+
sourceTableId: tableId
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// return {
|
|
96
|
+
// ...row,
|
|
97
|
+
// isMultipleDrag,
|
|
98
|
+
// draggedRows: isMultipleDrag ? selectedRows : [row],
|
|
99
|
+
// sourceTableId: tableId,
|
|
100
|
+
// };
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
type: 'TABLE_ROW'
|
|
104
|
+
}),
|
|
105
|
+
_useDrag2 = _slicedToArray(_useDrag, 3),
|
|
106
|
+
isDragging = _useDrag2[0].isDragging,
|
|
107
|
+
dragRef = _useDrag2[1],
|
|
108
|
+
preview = _useDrag2[2];
|
|
109
|
+
useEffect(function () {
|
|
110
|
+
// 隐藏拖拽dom
|
|
111
|
+
canRowDrag && preview(getEmptyImage(), {
|
|
112
|
+
captureDraggingState: true
|
|
113
|
+
});
|
|
114
|
+
}, [canRowDrag]);
|
|
115
|
+
|
|
116
|
+
// useEffect(() => {
|
|
117
|
+
// setCenterSubRowHeight(centerSubRowRef?.current?.clientHeight);
|
|
118
|
+
// console.log('centerSubRowRef?.current?.clientHeight=====', position, row, centerSubRowRef?.current?.clientHeight)
|
|
119
|
+
// }, [centerSubRowRef?.current?.clientHeight, position]);
|
|
120
|
+
|
|
121
|
+
useEffect(function () {
|
|
122
|
+
setSelectedRowDragging && row.getIsSelected() && setSelectedRowDragging(isDragging);
|
|
123
|
+
}, [isDragging, row.getIsSelected()]);
|
|
124
|
+
var rowClickHandler = function rowClickHandler(evt) {
|
|
125
|
+
// 触发单击事件
|
|
126
|
+
onRowMouseClick === null || onRowMouseClick === void 0 || onRowMouseClick(row);
|
|
127
|
+
if (!selectRowWhenClick) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (canSelection) {
|
|
131
|
+
var selectionConfig = _objectSpread(_objectSpread({}, table.getState().rowSelection), {}, _defineProperty({}, row.id, !row.getIsSelected()));
|
|
132
|
+
row.getCanSelect() && (table === null || table === void 0 ? void 0 : table.setRowSelection(selectionConfig));
|
|
133
|
+
onSelectChange === null || onSelectChange === void 0 || onSelectChange(row, row === null || row === void 0 ? void 0 : row.original, row.getCanSelect() ? !row.getIsSelected() : false, evt);
|
|
134
|
+
} else {
|
|
135
|
+
setRowSelectedId === null || setRowSelectedId === void 0 || setRowSelectedId(row === null || row === void 0 ? void 0 : row.id);
|
|
136
|
+
selectedRowChange === null || selectedRowChange === void 0 || selectedRowChange(row);
|
|
137
|
+
onSelectChange === null || onSelectChange === void 0 || onSelectChange(row, row === null || row === void 0 ? void 0 : row.original, true, evt);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var rowClickOrDoubleClick = function rowClickOrDoubleClick(e) {
|
|
141
|
+
// console.log('rowClickOrDoubleClick');
|
|
142
|
+
if (editting) return;
|
|
143
|
+
if (onRowMouseDoubleClick) {
|
|
144
|
+
// 监听了双击事件
|
|
145
|
+
if (!timerRef.current) {
|
|
146
|
+
timerRef.current = setTimeout(function () {
|
|
147
|
+
rowClickHandler(e);
|
|
148
|
+
clearTimeout(timerRef.current);
|
|
149
|
+
timerRef.current = undefined;
|
|
150
|
+
}, 300);
|
|
151
|
+
} else {
|
|
152
|
+
clearTimeout(timerRef.current);
|
|
153
|
+
timerRef.current = undefined;
|
|
154
|
+
onRowMouseDoubleClick(row);
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
// 没有监听双击事件,直接触发单击逻辑
|
|
158
|
+
rowClickHandler(e);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var rowMouseEnter = function rowMouseEnter() {
|
|
162
|
+
onRowMouseEnter === null || onRowMouseEnter === void 0 || onRowMouseEnter(row);
|
|
163
|
+
};
|
|
164
|
+
var rowMouseLeave = function rowMouseLeave() {
|
|
165
|
+
onRowMouseLeave === null || onRowMouseLeave === void 0 || onRowMouseLeave(row);
|
|
166
|
+
};
|
|
167
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
168
|
+
children: [/*#__PURE__*/_jsx("tr", {
|
|
169
|
+
// ref={canRowDrag && !editting ? dropRef : null}
|
|
170
|
+
ref: function ref(node) {
|
|
171
|
+
dropRef(node && !editting ? node : null);
|
|
172
|
+
dragRef(node && canRowDrag && !editting && !disableDragRowIds.includes(row.id) ? node : null);
|
|
173
|
+
},
|
|
174
|
+
style: _objectSpread({
|
|
175
|
+
opacity: isDragging || selectedRowDragging && row.getIsSelected() ? 0.5 : 1,
|
|
176
|
+
cursor: canRowDrag && !editting && !disableDragRowIds.includes(row.id) ? 'move' : 'auto'
|
|
177
|
+
}, rowStyle),
|
|
178
|
+
onClick: rowClickOrDoubleClick,
|
|
179
|
+
onMouseEnter: rowMouseEnter,
|
|
180
|
+
onMouseLeave: rowMouseLeave,
|
|
181
|
+
className: "\n 'tbody-tr' ".concat(String(row.id) === String(rowSelectedId) || row.getIsSelected() ? "tbody-tr-selected tbody-tr-selected" : '', " ").concat((rowClassName === null || rowClassName === void 0 ? void 0 : rowClassName(row).map(function (item) {
|
|
182
|
+
return "".concat(item);
|
|
183
|
+
}).join(' ')) || ''),
|
|
184
|
+
children: (_row = row["getVisibleCells"]) === null || _row === void 0 ? void 0 : _row.call(row).map(function (cell, idx) {
|
|
185
|
+
var _cell$column$columnDe = cell.column.columnDef,
|
|
186
|
+
editable = _cell$column$columnDe.editable,
|
|
187
|
+
required = _cell$column$columnDe.required,
|
|
188
|
+
accessorKey = _cell$column$columnDe.accessorKey,
|
|
189
|
+
header = _cell$column$columnDe.header,
|
|
190
|
+
columnClassName = _cell$column$columnDe.columnClassName;
|
|
191
|
+
var editStatus = edittingRowStatus && editable;
|
|
192
|
+
return /*#__PURE__*/_jsx("td", _objectSpread(_objectSpread({
|
|
193
|
+
className: "".concat(editStatus ? 'tbody-tr-td-editting' : '', " tbody-tr-td ").concat(columnClassName ? columnClassName.join(' ') : '', " ").concat((cellClassName === null || cellClassName === void 0 ? void 0 : cellClassName(cell).map(function (item) {
|
|
194
|
+
return "".concat(item, "-").concat(theme);
|
|
195
|
+
})) || '', " tbody-tr-td"),
|
|
196
|
+
style: _objectSpread({
|
|
197
|
+
height: rowHeight - 1
|
|
198
|
+
}, getPinningStyle(cell, table, false))
|
|
199
|
+
}, getCellProps === null || getCellProps === void 0 ? void 0 : getCellProps(cell.getContext())), {}, {
|
|
200
|
+
children: EditableCell(_objectSpread(_objectSpread({}, cell.column.columnDef), {}, {
|
|
201
|
+
editing: editStatus,
|
|
202
|
+
dataIndex: accessorKey,
|
|
203
|
+
title: header,
|
|
204
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
205
|
+
}))
|
|
206
|
+
}), cell.id);
|
|
207
|
+
})
|
|
208
|
+
}), row.getIsExpanded() && /*#__PURE__*/_jsx("tr", {
|
|
209
|
+
className: 'tbody-tr-subrow',
|
|
210
|
+
children: /*#__PURE__*/_jsx("td", {
|
|
211
|
+
colSpan: (_row2 = row["getVisibleCells"]) === null || _row2 === void 0 ? void 0 : _row2.call(row).length,
|
|
212
|
+
style: {
|
|
213
|
+
padding: 0
|
|
214
|
+
},
|
|
215
|
+
children: tableContainerWidth && /*#__PURE__*/_jsx("div", {
|
|
216
|
+
id: "".concat(tableId, "_expand-table"),
|
|
217
|
+
className: 'subRowWrapper'
|
|
218
|
+
// 减去10,避免被父表滚动条覆盖
|
|
219
|
+
,
|
|
220
|
+
style: {
|
|
221
|
+
width: "".concat(tableContainerWidth - (hasVerticalScrollBar ? 10 : 0), "px")
|
|
222
|
+
},
|
|
223
|
+
children: renderSubComponent && renderSubComponent({
|
|
224
|
+
row: row
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
})
|
|
228
|
+
})]
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
export default Row;
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { Spin } from 'antd';
|
|
2
|
+
import { CustomDragLayer } from "../components/CustomDragerLayer";
|
|
3
|
+
import "./index.less";
|
|
4
|
+
import Row from "./Row";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
var TableBody = function TableBody(_ref) {
|
|
9
|
+
var _headerGroups;
|
|
10
|
+
var table = _ref.table,
|
|
11
|
+
tableId = _ref.tableId,
|
|
12
|
+
reorderRow = _ref.reorderRow,
|
|
13
|
+
rowSelectedId = _ref.rowSelectedId,
|
|
14
|
+
setRowSelectedId = _ref.setRowSelectedId,
|
|
15
|
+
selectedRowChange = _ref.selectedRowChange,
|
|
16
|
+
onSelectChange = _ref.onSelectChange,
|
|
17
|
+
canFilter = _ref.canFilter,
|
|
18
|
+
canSelection = _ref.canSelection,
|
|
19
|
+
rowSelectionChange = _ref.rowSelectionChange,
|
|
20
|
+
scroll = _ref.scroll,
|
|
21
|
+
setScroll = _ref.setScroll,
|
|
22
|
+
tableBodyHeight = _ref.tableBodyHeight,
|
|
23
|
+
tableHeadHeight = _ref.tableHeadHeight,
|
|
24
|
+
setTableHeadHeight = _ref.setTableHeadHeight,
|
|
25
|
+
bodyContentHeight = _ref.bodyContentHeight,
|
|
26
|
+
setBodyContentHeight = _ref.setBodyContentHeight,
|
|
27
|
+
tableContainerWidth = _ref.tableContainerWidth,
|
|
28
|
+
selectedRowDragging = _ref.selectedRowDragging,
|
|
29
|
+
setSelectedRowDragging = _ref.setSelectedRowDragging,
|
|
30
|
+
canRowDrag = _ref.canRowDrag,
|
|
31
|
+
rowKey = _ref.rowKey,
|
|
32
|
+
loading = _ref.loading,
|
|
33
|
+
rowClassName = _ref.rowClassName,
|
|
34
|
+
cellClassName = _ref.cellClassName,
|
|
35
|
+
rowStyle = _ref.rowStyle,
|
|
36
|
+
getCellProps = _ref.getCellProps,
|
|
37
|
+
rowHeight = _ref.rowHeight,
|
|
38
|
+
editting = _ref.editting,
|
|
39
|
+
selectEditKey = _ref.selectEditKey,
|
|
40
|
+
renderSubComponent = _ref.renderSubComponent,
|
|
41
|
+
isAllRowExpanded = _ref.isAllRowExpanded,
|
|
42
|
+
onRowMouseEnter = _ref.onRowMouseEnter,
|
|
43
|
+
onRowMouseLeave = _ref.onRowMouseLeave,
|
|
44
|
+
onRowMouseClick = _ref.onRowMouseClick,
|
|
45
|
+
onRowMouseDoubleClick = _ref.onRowMouseDoubleClick,
|
|
46
|
+
enableFilters = _ref.enableFilters,
|
|
47
|
+
enableVirtualList = _ref.enableVirtualList,
|
|
48
|
+
disableDragRowIds = _ref.disableDragRowIds,
|
|
49
|
+
selectRowWhenClick = _ref.selectRowWhenClick,
|
|
50
|
+
hasVerticalScrollBar = _ref.hasVerticalScrollBar,
|
|
51
|
+
datas = _ref.datas,
|
|
52
|
+
emptyDataHeight = _ref.emptyDataHeight;
|
|
53
|
+
// const tbodyRef = useRef<any>(null);
|
|
54
|
+
// const theadRef = useRef<any>(null);
|
|
55
|
+
// const { theme } = useContext(layoutContext);
|
|
56
|
+
var _dark = 'dark',
|
|
57
|
+
theme = _dark.theme;
|
|
58
|
+
var headerGroups = table.getHeaderGroups();
|
|
59
|
+
|
|
60
|
+
// const { rows } = table.getRowModel();
|
|
61
|
+
|
|
62
|
+
// useEffect(() => {
|
|
63
|
+
// if (tbodyRef.current) {
|
|
64
|
+
// console.log('tbodyRef.current.scrollHeight', tbodyRef.current.scrollHeight)
|
|
65
|
+
// console.log('tbodyRef.current.scrollTop', tbodyRef.current.scrollTop, scroll)
|
|
66
|
+
// tbodyRef.current.scrollTop = scroll;
|
|
67
|
+
// }
|
|
68
|
+
// let ele = document.getElementById('tbody')
|
|
69
|
+
// if (ele) {
|
|
70
|
+
// console.log('4444444', ele, ele.scrollTop)
|
|
71
|
+
// ele.scrollTop = scroll
|
|
72
|
+
// }
|
|
73
|
+
|
|
74
|
+
// }, [scroll]);
|
|
75
|
+
|
|
76
|
+
// useLayoutEffect(() => {
|
|
77
|
+
// if (theadRef.current) {
|
|
78
|
+
// const theadHeight = theadRef.current.clientHeight;
|
|
79
|
+
// theadHeight !== tableHeadHeight ? setTableHeadHeight(theadHeight) : null;
|
|
80
|
+
// }
|
|
81
|
+
// }, [theadRef?.current, theadRef?.current?.clientHeight, enableFilters]);
|
|
82
|
+
|
|
83
|
+
// const scrollDataRef = useRef<any>({
|
|
84
|
+
// scroll,
|
|
85
|
+
// bodyContentHeight,
|
|
86
|
+
// tableBodyHeight,
|
|
87
|
+
// });
|
|
88
|
+
// useLayoutEffect(() => {
|
|
89
|
+
// scrollDataRef.current = {
|
|
90
|
+
// scroll,
|
|
91
|
+
// bodyContentHeight,
|
|
92
|
+
// tableBodyHeight,
|
|
93
|
+
// };
|
|
94
|
+
// }, [scroll, bodyContentHeight, tableBodyHeight]);
|
|
95
|
+
// // const handleWheel = (event: WheelEvent) => {
|
|
96
|
+
// // const {
|
|
97
|
+
// // scroll: refDataScroll,
|
|
98
|
+
// // bodyContentHeight: refDataBodyContentHeight,
|
|
99
|
+
// // tableBodyHeight: refDataTableBodyHeight,
|
|
100
|
+
// // } = scrollDataRef.current;
|
|
101
|
+
|
|
102
|
+
// // let newScroll = refDataScroll + event.deltaY || 0;
|
|
103
|
+
// // const maxScroll = refDataBodyContentHeight - refDataTableBodyHeight;
|
|
104
|
+
// // if (newScroll < 0) {
|
|
105
|
+
// // newScroll = 0;
|
|
106
|
+
// // } else if (newScroll > maxScroll) {
|
|
107
|
+
// // newScroll = maxScroll;
|
|
108
|
+
// // }
|
|
109
|
+
// // setScroll?.(newScroll);
|
|
110
|
+
|
|
111
|
+
// // if (!((refDataScroll == 0 && newScroll == 0) || (refDataScroll === maxScroll && newScroll === maxScroll))) {
|
|
112
|
+
// // event.stopPropagation();
|
|
113
|
+
// // event.preventDefault();
|
|
114
|
+
// // }
|
|
115
|
+
// // };
|
|
116
|
+
|
|
117
|
+
// // table-body 监听滚轮事件
|
|
118
|
+
// // useEffect(() => {
|
|
119
|
+
// // tbodyRef.current?.addEventListener('wheel', handleWheel, { passive: false });
|
|
120
|
+
// // return () => tbodyRef.current?.removeEventListener('wheel', handleWheel, { passive: false });
|
|
121
|
+
// // }, [tbodyRef.current]);
|
|
122
|
+
|
|
123
|
+
// // 是否展开所有行
|
|
124
|
+
// useEffect(() => {
|
|
125
|
+
// isAllRowExpanded && table?.toggleAllRowsExpanded();
|
|
126
|
+
// }, [isAllRowExpanded]);
|
|
127
|
+
|
|
128
|
+
// // 虚拟列表
|
|
129
|
+
// const rowVirtualizer = useVirtualizer({
|
|
130
|
+
// count: rows.length, // 数据总条数
|
|
131
|
+
// getScrollElement: () => tbodyRef.current, // 外层滚动的dom元素
|
|
132
|
+
// estimateSize: () => rowHeight, // 每一行的预估高度值
|
|
133
|
+
// overscan: enableVirtualList ? 5 : 9999, // 上下额外展示的数据量
|
|
134
|
+
// });
|
|
135
|
+
|
|
136
|
+
// const rowVirtualizerTotalHeight = rowVirtualizer.getTotalSize();
|
|
137
|
+
|
|
138
|
+
// // 展开状态变化之后重新设定table内容高度(不能作用于left\right-table)
|
|
139
|
+
// useLayoutEffect(() => {
|
|
140
|
+
// // if (position !== 'Left' && position !== 'Right') {
|
|
141
|
+
// rowVirtualizerTotalHeight && setBodyContentHeight(rowVirtualizerTotalHeight);
|
|
142
|
+
// // }
|
|
143
|
+
// }, [rowVirtualizerTotalHeight]);
|
|
144
|
+
|
|
145
|
+
// console.log('object', rowVirtualizer.getVirtualItems(), rows);
|
|
146
|
+
|
|
147
|
+
var EmptyContent = function EmptyContent() {
|
|
148
|
+
return /*#__PURE__*/_jsx("tr", {
|
|
149
|
+
className: 'empty-container',
|
|
150
|
+
style: {
|
|
151
|
+
width: table.getTotalSize()
|
|
152
|
+
},
|
|
153
|
+
children: /*#__PURE__*/_jsx("td", {
|
|
154
|
+
className: 'empty-wapper',
|
|
155
|
+
style: {
|
|
156
|
+
width: "".concat(tableContainerWidth - (hasVerticalScrollBar ? 10 : 0), "px"),
|
|
157
|
+
height: emptyDataHeight
|
|
158
|
+
},
|
|
159
|
+
children: loading ? /*#__PURE__*/_jsx(Spin, {}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
160
|
+
children: [/*#__PURE__*/_jsx("img", {
|
|
161
|
+
className: 'empty-img',
|
|
162
|
+
src: "/images/data-empty-".concat(theme, ".png"),
|
|
163
|
+
height: "60"
|
|
164
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
165
|
+
className: 'empty-text',
|
|
166
|
+
children: "\u6682\u65E0\u6570\u636E"
|
|
167
|
+
})]
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
var TBodyContent = function TBodyContent() {
|
|
173
|
+
return table.getRowModel().rows.map(function (row) {
|
|
174
|
+
var edittingRowStatus = row.id == selectEditKey && editting;
|
|
175
|
+
return /*#__PURE__*/_jsx(Row, {
|
|
176
|
+
table: table,
|
|
177
|
+
tableId: tableId,
|
|
178
|
+
tableContainerWidth: tableContainerWidth,
|
|
179
|
+
row: row,
|
|
180
|
+
reorderRow: reorderRow,
|
|
181
|
+
rowSelectedId: rowSelectedId,
|
|
182
|
+
setRowSelectedId: setRowSelectedId,
|
|
183
|
+
selectedRowChange: selectedRowChange,
|
|
184
|
+
onSelectChange: onSelectChange,
|
|
185
|
+
canSelection: canSelection,
|
|
186
|
+
selectedRowDragging: selectedRowDragging,
|
|
187
|
+
setSelectedRowDragging: setSelectedRowDragging,
|
|
188
|
+
rowSelectionChange: rowSelectionChange,
|
|
189
|
+
canRowDrag: canRowDrag,
|
|
190
|
+
rowKey: rowKey,
|
|
191
|
+
rowClassName: rowClassName,
|
|
192
|
+
cellClassName: cellClassName,
|
|
193
|
+
rowStyle: rowStyle,
|
|
194
|
+
getCellProps: getCellProps,
|
|
195
|
+
editting: editting,
|
|
196
|
+
edittingRowStatus: edittingRowStatus,
|
|
197
|
+
renderSubComponent: renderSubComponent,
|
|
198
|
+
onRowMouseEnter: onRowMouseEnter,
|
|
199
|
+
onRowMouseLeave: onRowMouseLeave,
|
|
200
|
+
onRowMouseClick: onRowMouseClick,
|
|
201
|
+
onRowMouseDoubleClick: onRowMouseDoubleClick,
|
|
202
|
+
rowHeight: rowHeight,
|
|
203
|
+
disableDragRowIds: disableDragRowIds,
|
|
204
|
+
selectRowWhenClick: selectRowWhenClick,
|
|
205
|
+
hasVerticalScrollBar: hasVerticalScrollBar
|
|
206
|
+
}, row.id);
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
var tbodyRender = function tbodyRender() {
|
|
210
|
+
if (!loading && datas.length !== 0) {
|
|
211
|
+
return TBodyContent();
|
|
212
|
+
}
|
|
213
|
+
return EmptyContent();
|
|
214
|
+
};
|
|
215
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
216
|
+
className: 'table-tbody',
|
|
217
|
+
style: {
|
|
218
|
+
height: "".concat(tableBodyHeight, "px"),
|
|
219
|
+
width: table.getTotalSize()
|
|
220
|
+
},
|
|
221
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
222
|
+
children: canRowDrag && !editting && /*#__PURE__*/_jsx(CustomDragLayer, {
|
|
223
|
+
getCellProps: getCellProps,
|
|
224
|
+
rowClassName: rowClassName,
|
|
225
|
+
cellClassName: cellClassName,
|
|
226
|
+
rowStyle: rowStyle,
|
|
227
|
+
theme: theme,
|
|
228
|
+
rowSelectedId: rowSelectedId,
|
|
229
|
+
table: table
|
|
230
|
+
})
|
|
231
|
+
}), /*#__PURE__*/_jsxs("table", {
|
|
232
|
+
style: {
|
|
233
|
+
width: table.getTotalSize()
|
|
234
|
+
},
|
|
235
|
+
children: [/*#__PURE__*/_jsx("colgroup", {
|
|
236
|
+
children: headerGroups === null || headerGroups === void 0 || (_headerGroups = headerGroups[headerGroups.length - 1]) === null || _headerGroups === void 0 || (_headerGroups = _headerGroups.headers) === null || _headerGroups === void 0 ? void 0 : _headerGroups.map(function (header) {
|
|
237
|
+
return /*#__PURE__*/_jsx("col", {
|
|
238
|
+
style: {
|
|
239
|
+
width: header.getSize() || 80
|
|
240
|
+
}
|
|
241
|
+
}, header.id);
|
|
242
|
+
})
|
|
243
|
+
}), /*#__PURE__*/_jsx("tbody", {
|
|
244
|
+
children: tbodyRender()
|
|
245
|
+
})]
|
|
246
|
+
})]
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
export default TableBody;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
@globalColor0: #f5f6f7; // 文字颜色
|
|
2
|
+
@globalColor1: #05081a; // 文字颜色
|
|
3
|
+
@globalColor2: #5e6175;
|
|
4
|
+
@globalColor3: #838695;
|
|
5
|
+
@globalColor4: #dadbdf;
|
|
6
|
+
@globalColor5: #ececee; // 网格线色
|
|
7
|
+
@globalColor6: #f5f6f7;
|
|
8
|
+
@globalColor7: #ffffff; // 背景色
|
|
9
|
+
@globalColor8: #f5f6f7; // 背景衬托色
|
|
10
|
+
@globalColor9: #f7f7f9; // 网格遮罩色(passed)
|
|
11
|
+
@globalColor_18: #fdfdfe; // 网格遮罩色
|
|
12
|
+
@globalColor_10: #f5f6f7; // 网格遮罩色
|
|
13
|
+
@globalColor_11: #ececee; //
|
|
14
|
+
@globalColor_12: #838695; // 铁包运行左侧菜单线
|
|
15
|
+
@globalColor_13: #dadbdf; // 甘特图网格线颜色
|
|
16
|
+
@globalColor_14: #dadbdf; // 表头背景色
|
|
17
|
+
@globalColor_15: #C1C2CA; // 表格头线对应色
|
|
18
|
+
@globalColor_16: #F5F5F6; // 内嵌卡片背景
|
|
19
|
+
@globalColor_17: #C1C2CA; // 时间轴和工位栏颜色
|
|
20
|
+
|
|
21
|
+
@tableColor1: #212121; // 表格字体颜色
|
|
22
|
+
@tableColor2: rgba(94, 97, 117, 0.4); // 表格边框颜色
|
|
23
|
+
@tableColor3: #DADBDFFF; // 表格边框颜色
|
|
24
|
+
@tableColor4: #DADBDF7F; // 表格筛选区时间选择框分割线颜色
|
|
25
|
+
@tableColor5: #ffffff; // 表格列设置区拖拽图标颜色
|
|
26
|
+
@tableColor6: #FA541CFF; // 表格列设置区列显隐图标颜色
|
|
27
|
+
@tableColor7: #1A1D2EFF; // 表格列设置区列表元素边框颜色
|
|
28
|
+
@scrollThumb: rgba(255, 255, 255, 0.2);
|
|
29
|
+
@scrollThumbHover: rgba(255, 255, 255, 0.3);
|
|
30
|
+
@sliderRightBorder: #3e3b3b;
|
|
31
|
+
// @selectTableRow: var(--select-table-row, rgb(245 246 247 / 15%));
|
|
32
|
+
@selectTableRow: #d0e37b;
|
|
33
|
+
@globalColor_table-line: #f0f0f0; // table行分隔线颜色
|
|
34
|
+
|
|
35
|
+
table {
|
|
36
|
+
table-layout: fixed;
|
|
37
|
+
|
|
38
|
+
td {
|
|
39
|
+
border: 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.tbody {
|
|
44
|
+
background-color: @globalColor0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
.tbody-tr,
|
|
49
|
+
.tbody-tr-selected {
|
|
50
|
+
// display: flex;
|
|
51
|
+
transition: left, top;
|
|
52
|
+
transition-duration: 0.6s;
|
|
53
|
+
background-color: @globalColor0;
|
|
54
|
+
border-bottom: 1px solid @tableColor2;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.tbody-tr-td-editting {
|
|
58
|
+
// height: auto !important;
|
|
59
|
+
// padding: 8px !important;
|
|
60
|
+
// display: flex !important;
|
|
61
|
+
// align-items: center;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.tbody-tr-td,
|
|
65
|
+
.tbody-tr-td-drag,
|
|
66
|
+
.tbody-tr-selected>.tbody-tr-td,
|
|
67
|
+
.tbody-tr-selected>.tbody-tr-td-drag {
|
|
68
|
+
background-color: @globalColor0;
|
|
69
|
+
height: 39px;
|
|
70
|
+
line-height: 39px;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
text-overflow: ellipsis;
|
|
73
|
+
white-space: nowrap;
|
|
74
|
+
padding: 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.tbody-tr-selected>.tbody-tr-td,
|
|
78
|
+
.tbody-tr-selected>.tbody-tr-td-drag {
|
|
79
|
+
background: @selectTableRow;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.tbody-tr-td-drag:hover {
|
|
83
|
+
cursor: move;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.tbody-tr-subrow {
|
|
87
|
+
background: @globalColor_14;
|
|
88
|
+
|
|
89
|
+
.subRowWrapper {
|
|
90
|
+
padding-left: 40px;
|
|
91
|
+
position: sticky;
|
|
92
|
+
left: 0px;
|
|
93
|
+
overflow: hidden;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// .tbody-tr-subrow-light {
|
|
98
|
+
// border-bottom: 1px solid var(--tableColor2, rgba(94, 97, 117, 0.4));
|
|
99
|
+
// background: #fbfbfb;
|
|
100
|
+
// }
|
|
101
|
+
|
|
102
|
+
// .tbody-tr-subrow-dark {
|
|
103
|
+
// border-bottom: 1px solid #848695;
|
|
104
|
+
// background: rgba(94, 97, 117, 0.4);
|
|
105
|
+
// }
|
|
106
|
+
|
|
107
|
+
.table-loading {
|
|
108
|
+
display: flex;
|
|
109
|
+
flex-direction: column;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
align-items: center;
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: 100%;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.empty-container {
|
|
117
|
+
width: 100%;
|
|
118
|
+
height: 100%;
|
|
119
|
+
|
|
120
|
+
.empty-wapper {
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
justify-content: center;
|
|
124
|
+
align-items: center;
|
|
125
|
+
position: sticky;
|
|
126
|
+
left: 0;
|
|
127
|
+
|
|
128
|
+
.empty-content {
|
|
129
|
+
display: flex;
|
|
130
|
+
flex-direction: column;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
align-items: center;
|
|
133
|
+
width: 100%;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.empty-text {
|
|
138
|
+
color: @globalColor2;
|
|
139
|
+
font-size: 12px;
|
|
140
|
+
}
|
|
141
|
+
}
|