@arim-aisdc/public-components 0.0.5 → 0.0.7
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/dist/components/TableMax/TableBody/Row.d.ts +7 -1
- package/dist/components/TableMax/TableBody/Row.js +44 -11
- package/dist/components/TableMax/TableBody/index.d.ts +6 -3
- package/dist/components/TableMax/TableBody/index.js +39 -31
- package/dist/components/TableMax/TableBody/index.less +43 -8
- package/dist/components/TableMax/TableHeader/Cell.js +6 -22
- package/dist/components/TableMax/TableHeader/index.d.ts +5 -1
- package/dist/components/TableMax/TableHeader/index.js +13 -5
- package/dist/components/TableMax/TableHeader/index.less +28 -35
- package/dist/components/TableMax/TableHeader/utils.js +30 -24
- package/dist/components/TableMax/TableMax.d.ts +1 -0
- package/dist/components/TableMax/TableMax.js +303 -316
- package/dist/components/TableMax/components/ColumnFilter/FilterDateRange/index.js +28 -13
- package/dist/components/TableMax/components/ColumnFilter/index.js +2 -0
- package/dist/components/TableMax/components/ColumnSort/customSortFns.d.ts +10 -0
- package/dist/components/TableMax/components/ColumnSort/customSortFns.js +67 -0
- package/dist/components/TableMax/components/ColumnSort/index.d.ts +5 -0
- package/dist/components/TableMax/components/ColumnSort/index.js +27 -0
- package/dist/components/TableMax/components/ColumnSort/index.less +33 -0
- package/dist/components/TableMax/index.d.ts +1 -0
- package/dist/components/TableMax/type.d.ts +31 -9
- package/dist/components/TableMax/utils.d.ts +8 -0
- package/dist/components/TableMax/utils.js +59 -1
- package/dist/themes/theme.d.ts +2 -0
- package/dist/themes/theme.js +4 -0
- package/dist/themes/variables.less +1 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { OnSelectChangeType } from "../type";
|
|
|
2
2
|
import { Table } from '@tanstack/react-table';
|
|
3
3
|
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
|
4
4
|
import './index.less';
|
|
5
|
-
declare const Row: ({ table, tableId, row, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, reorderRow, tableContainerWidth, canRowDrag, rowClassName, cellClassName, rowStyle, getCellProps, editting, rowEditing, renderSubComponent, selectedRowDragging, setSelectedRowDragging, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, rowHeight, disableDragRowIds, selectRowWhenClick, hasVerticalScrollBar, handleEditRowWhenDClick, canEditRowWhenDClick, theme, }: {
|
|
5
|
+
declare const Row: ({ table, tableId, row, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, reorderRow, tableContainerWidth, canRowDrag, rowClassName, cellClassName, rowStyle, getCellProps, editting, rowEditing, renderSubComponent, selectedRowDragging, setSelectedRowDragging, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, rowHeight, disableDragRowIds, selectRowWhenClick, hasVerticalScrollBar, handleEditRowWhenDClick, canEditRowWhenDClick, theme, pinShadowVisible, dragBeforeStart, }: {
|
|
6
6
|
table: Table<any>;
|
|
7
7
|
tableId: string;
|
|
8
8
|
row: any;
|
|
@@ -36,5 +36,11 @@ declare const Row: ({ table, tableId, row, rowSelectedId, setRowSelectedId, sele
|
|
|
36
36
|
handleEditRowWhenDClick: (row: any) => void;
|
|
37
37
|
canEditRowWhenDClick: boolean;
|
|
38
38
|
theme: string;
|
|
39
|
+
pinShadowVisible: {
|
|
40
|
+
left: boolean;
|
|
41
|
+
right: boolean;
|
|
42
|
+
};
|
|
43
|
+
dragBeforeStart?: (datas: any) => boolean;
|
|
44
|
+
rowKey?: string;
|
|
39
45
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
40
46
|
export default Row;
|
|
@@ -16,6 +16,7 @@ import { useDrag, useDrop } from 'react-dnd';
|
|
|
16
16
|
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
17
17
|
import { EditableCell } from "../components/ColumnEdit";
|
|
18
18
|
import { getPinningStyle } from "../TableHeader/utils";
|
|
19
|
+
import { getShadowInfo } from "../utils";
|
|
19
20
|
import "./index.less";
|
|
20
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
22
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -52,7 +53,9 @@ var Row = function Row(_ref) {
|
|
|
52
53
|
hasVerticalScrollBar = _ref.hasVerticalScrollBar,
|
|
53
54
|
handleEditRowWhenDClick = _ref.handleEditRowWhenDClick,
|
|
54
55
|
canEditRowWhenDClick = _ref.canEditRowWhenDClick,
|
|
55
|
-
theme = _ref.theme
|
|
56
|
+
theme = _ref.theme,
|
|
57
|
+
pinShadowVisible = _ref.pinShadowVisible,
|
|
58
|
+
dragBeforeStart = _ref.dragBeforeStart;
|
|
56
59
|
var timerRef = useRef();
|
|
57
60
|
var _useDrop = useDrop({
|
|
58
61
|
accept: 'TABLE_ROW',
|
|
@@ -73,7 +76,7 @@ var Row = function Row(_ref) {
|
|
|
73
76
|
var _useDrag = useDrag({
|
|
74
77
|
collect: function collect(monitor) {
|
|
75
78
|
return {
|
|
76
|
-
isDragging: monitor.isDragging()
|
|
79
|
+
isDragging: monitor !== null && monitor !== void 0 && monitor.getItem() ? dragBeforeStart === null || dragBeforeStart === void 0 ? void 0 : dragBeforeStart(monitor === null || monitor === void 0 ? void 0 : monitor.getItem()) : monitor.isDragging()
|
|
77
80
|
};
|
|
78
81
|
},
|
|
79
82
|
item: function item() {
|
|
@@ -90,15 +93,7 @@ var Row = function Row(_ref) {
|
|
|
90
93
|
draggedRows: isMultipleDrag ? selectedRows : [row],
|
|
91
94
|
sourceTableId: tableId
|
|
92
95
|
};
|
|
93
|
-
|
|
94
|
-
// return {
|
|
95
|
-
// ...row,
|
|
96
|
-
// isMultipleDrag,
|
|
97
|
-
// draggedRows: isMultipleDrag ? selectedRows : [row],
|
|
98
|
-
// sourceTableId: tableId,
|
|
99
|
-
// };
|
|
100
96
|
},
|
|
101
|
-
|
|
102
97
|
type: 'TABLE_ROW'
|
|
103
98
|
}),
|
|
104
99
|
_useDrag2 = _slicedToArray(_useDrag, 3),
|
|
@@ -143,6 +138,39 @@ var Row = function Row(_ref) {
|
|
|
143
138
|
onSelectChange === null || onSelectChange === void 0 || onSelectChange(row, row === null || row === void 0 ? void 0 : row.original, true, evt);
|
|
144
139
|
}
|
|
145
140
|
};
|
|
141
|
+
|
|
142
|
+
// const rowClickHandler = (evt: any) => {
|
|
143
|
+
// // 触发单击回调
|
|
144
|
+
// onRowMouseClick?.(row);
|
|
145
|
+
|
|
146
|
+
// if (!selectRowWhenClick) {
|
|
147
|
+
// // 如果配置了selectRowWhenClick这个props,单击时不选中
|
|
148
|
+
// return;
|
|
149
|
+
// }
|
|
150
|
+
|
|
151
|
+
// const selectionConfig = {
|
|
152
|
+
// ...table.getState().rowSelection
|
|
153
|
+
// };
|
|
154
|
+
// if (canSelection) {
|
|
155
|
+
// if (evt.ctrlKey) {
|
|
156
|
+
// if (!row.getIsSelected()) {
|
|
157
|
+
// selectionConfig[row.id] = true
|
|
158
|
+
// } else {
|
|
159
|
+
// delete selectionConfig[row.id]
|
|
160
|
+
// }
|
|
161
|
+
// } else if ({ ...table.getState().rowSelection }[row.id]) {
|
|
162
|
+
// delete selectionConfig[row.id]
|
|
163
|
+
// }
|
|
164
|
+
// if (row.getCanSelect()) {
|
|
165
|
+
// table?.setRowSelection(selectionConfig);
|
|
166
|
+
// }
|
|
167
|
+
// }
|
|
168
|
+
// setRowSelectedId?.(row?.id);
|
|
169
|
+
// selectedRowChange?.(row);
|
|
170
|
+
// onSelectChange?.(row, row?.original, true, evt);
|
|
171
|
+
|
|
172
|
+
// };
|
|
173
|
+
|
|
146
174
|
var rowClickOrDoubleClick = function rowClickOrDoubleClick(e) {
|
|
147
175
|
// console.log('rowClickOrDoubleClick');
|
|
148
176
|
if (editting) return;
|
|
@@ -199,8 +227,13 @@ var Row = function Row(_ref) {
|
|
|
199
227
|
columnClassName = _cell$column$columnDe.columnClassName;
|
|
200
228
|
// 当前列是否编辑中
|
|
201
229
|
var columnEditing = rowEditing && columnEditable;
|
|
230
|
+
|
|
231
|
+
// 列固定时的阴影判断逻辑
|
|
232
|
+
var _getShadowInfo = getShadowInfo(cell.column, table),
|
|
233
|
+
isRightFirst = _getShadowInfo.isRightFirst,
|
|
234
|
+
isLeftLast = _getShadowInfo.isLeftLast;
|
|
202
235
|
return /*#__PURE__*/_jsx("td", _objectSpread(_objectSpread({
|
|
203
|
-
className: "".concat(columnEditing ? 'tbody-tr-td-editting' : '', " ").concat(columnClassName ? columnClassName.join(' ') : '', " ").concat((cellClassName === null || cellClassName === void 0 ? void 0 : cellClassName(cell).map(function (item) {
|
|
236
|
+
className: "".concat(columnEditing ? 'tbody-tr-td-editting' : '', " ").concat(isLeftLast && pinShadowVisible.left ? 'tbody-tr-td-cell-fix-left-last' : '', " ").concat(isRightFirst && pinShadowVisible.right ? 'tbody-tr-td-cell-fix-right-first' : '', " ").concat(columnClassName ? columnClassName.join(' ') : '', " ").concat((cellClassName === null || cellClassName === void 0 ? void 0 : cellClassName(cell).map(function (item) {
|
|
204
237
|
return "".concat(item, "-").concat(theme);
|
|
205
238
|
})) || '', " tbody-tr-td"),
|
|
206
239
|
style: _objectSpread({
|
|
@@ -14,8 +14,6 @@ type TableBodyPropsType = {
|
|
|
14
14
|
canFilter: boolean;
|
|
15
15
|
canSelection: boolean;
|
|
16
16
|
tableBodyHeight: number;
|
|
17
|
-
tableHeadHeight: number;
|
|
18
|
-
setTableHeadHeight: Dispatch<SetStateAction<number>>;
|
|
19
17
|
bodyContentHeight: number;
|
|
20
18
|
tableContainerWidth: number;
|
|
21
19
|
selectedRowDragging: boolean;
|
|
@@ -48,6 +46,11 @@ type TableBodyPropsType = {
|
|
|
48
46
|
canEditRowWhenDClick: boolean;
|
|
49
47
|
editingRowId: string;
|
|
50
48
|
handleEditRowWhenDClick: (row: any) => void;
|
|
49
|
+
pinShadowVisible: {
|
|
50
|
+
left: boolean;
|
|
51
|
+
right: boolean;
|
|
52
|
+
};
|
|
53
|
+
dragBeforeStart: (datas: any) => boolean;
|
|
51
54
|
};
|
|
52
|
-
declare const TableBody: ({ table, tableId, theme, reorderRow, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, tableBodyHeight, tableContainerWidth, selectedRowDragging, setSelectedRowDragging, canRowDrag, loading, rowClassName, cellClassName, rowStyle, getCellProps, rowHeight, renderSubComponent, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, disableDragRowIds, selectRowWhenClick, hasVerticalScrollBar, datas, emptyDataHeight, canEditRowWhenDClick, editingRowId, handleEditRowWhenDClick, }: TableBodyPropsType) => import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
declare const TableBody: ({ table, tableId, theme, reorderRow, rowSelectedId, setRowSelectedId, selectedRowChange, onSelectChange, canSelection, tableBodyHeight, tableContainerWidth, selectedRowDragging, setSelectedRowDragging, canRowDrag, rowKey, loading, rowClassName, cellClassName, rowStyle, getCellProps, rowHeight, renderSubComponent, onRowMouseEnter, onRowMouseLeave, onRowMouseClick, onRowMouseDoubleClick, disableDragRowIds, selectRowWhenClick, hasVerticalScrollBar, datas, emptyDataHeight, canEditRowWhenDClick, editingRowId, handleEditRowWhenDClick, pinShadowVisible, dragBeforeStart, }: TableBodyPropsType) => import("react/jsx-runtime").JSX.Element;
|
|
53
56
|
export default TableBody;
|
|
@@ -12,11 +12,13 @@ import { useDrop } from 'react-dnd';
|
|
|
12
12
|
import { CustomDragLayer } from "../components/CustomDragerLayer";
|
|
13
13
|
// import RowContent from "../components/RowContent";
|
|
14
14
|
|
|
15
|
+
import { useEffect } from 'react';
|
|
15
16
|
import { createPortal } from 'react-dom';
|
|
16
17
|
import Row from "./Row";
|
|
17
18
|
import "./index.less";
|
|
18
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
20
22
|
var TableBody = function TableBody(_ref) {
|
|
21
23
|
var _headerGroups;
|
|
22
24
|
var table = _ref.table,
|
|
@@ -33,6 +35,7 @@ var TableBody = function TableBody(_ref) {
|
|
|
33
35
|
selectedRowDragging = _ref.selectedRowDragging,
|
|
34
36
|
setSelectedRowDragging = _ref.setSelectedRowDragging,
|
|
35
37
|
canRowDrag = _ref.canRowDrag,
|
|
38
|
+
rowKey = _ref.rowKey,
|
|
36
39
|
loading = _ref.loading,
|
|
37
40
|
rowClassName = _ref.rowClassName,
|
|
38
41
|
cellClassName = _ref.cellClassName,
|
|
@@ -51,7 +54,9 @@ var TableBody = function TableBody(_ref) {
|
|
|
51
54
|
emptyDataHeight = _ref.emptyDataHeight,
|
|
52
55
|
canEditRowWhenDClick = _ref.canEditRowWhenDClick,
|
|
53
56
|
editingRowId = _ref.editingRowId,
|
|
54
|
-
handleEditRowWhenDClick = _ref.handleEditRowWhenDClick
|
|
57
|
+
handleEditRowWhenDClick = _ref.handleEditRowWhenDClick,
|
|
58
|
+
pinShadowVisible = _ref.pinShadowVisible,
|
|
59
|
+
dragBeforeStart = _ref.dragBeforeStart;
|
|
55
60
|
// const tbodyRef = useRef<any>(null);
|
|
56
61
|
// const theadRef = useRef<any>(null);
|
|
57
62
|
var headerGroups = table.getHeaderGroups();
|
|
@@ -193,6 +198,7 @@ var TableBody = function TableBody(_ref) {
|
|
|
193
198
|
tableId: tableId,
|
|
194
199
|
tableContainerWidth: tableContainerWidth,
|
|
195
200
|
row: row,
|
|
201
|
+
rowKey: rowKey,
|
|
196
202
|
theme: theme,
|
|
197
203
|
reorderRow: reorderRow,
|
|
198
204
|
rowSelectedId: rowSelectedId,
|
|
@@ -203,6 +209,7 @@ var TableBody = function TableBody(_ref) {
|
|
|
203
209
|
selectedRowDragging: selectedRowDragging,
|
|
204
210
|
setSelectedRowDragging: setSelectedRowDragging,
|
|
205
211
|
canRowDrag: canRowDrag,
|
|
212
|
+
dragBeforeStart: dragBeforeStart,
|
|
206
213
|
rowClassName: rowClassName,
|
|
207
214
|
cellClassName: cellClassName,
|
|
208
215
|
rowStyle: rowStyle,
|
|
@@ -219,7 +226,8 @@ var TableBody = function TableBody(_ref) {
|
|
|
219
226
|
selectRowWhenClick: selectRowWhenClick,
|
|
220
227
|
hasVerticalScrollBar: hasVerticalScrollBar,
|
|
221
228
|
handleEditRowWhenDClick: handleEditRowWhenDClick,
|
|
222
|
-
canEditRowWhenDClick: canEditRowWhenDClick
|
|
229
|
+
canEditRowWhenDClick: canEditRowWhenDClick,
|
|
230
|
+
pinShadowVisible: pinShadowVisible
|
|
223
231
|
}, row.id);
|
|
224
232
|
});
|
|
225
233
|
};
|
|
@@ -229,35 +237,35 @@ var TableBody = function TableBody(_ref) {
|
|
|
229
237
|
}
|
|
230
238
|
return EmptyContent();
|
|
231
239
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
})
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
240
|
+
useEffect(function () {
|
|
241
|
+
console.log(tableBodyHeight, 'tableBodyHeight*******************');
|
|
242
|
+
}, [tableBodyHeight]);
|
|
243
|
+
return (
|
|
244
|
+
/*#__PURE__*/
|
|
245
|
+
// 修复筛选数据为空时,滚动条丢失
|
|
246
|
+
_jsxs(_Fragment, {
|
|
247
|
+
children: [canRowDrag && !editingRowId && /*#__PURE__*/createPortal( /*#__PURE__*/_jsx(CustomDragLayer, {
|
|
248
|
+
getCellProps: getCellProps,
|
|
249
|
+
rowClassName: rowClassName,
|
|
250
|
+
cellClassName: cellClassName,
|
|
251
|
+
rowStyle: rowStyle,
|
|
252
|
+
theme: theme,
|
|
253
|
+
rowSelectedId: rowSelectedId,
|
|
254
|
+
table: table,
|
|
255
|
+
tableId: tableId
|
|
256
|
+
}), document.body), /*#__PURE__*/_jsxs("table", {
|
|
257
|
+
children: [/*#__PURE__*/_jsx("colgroup", {
|
|
258
|
+
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) {
|
|
259
|
+
return /*#__PURE__*/_jsx("col", {
|
|
260
|
+
width: header.getSize() || 80
|
|
261
|
+
}, header.id);
|
|
262
|
+
})
|
|
263
|
+
}), /*#__PURE__*/_jsx("tbody", {
|
|
264
|
+
id: "table-max-tableBody-tbody-".concat(tableId),
|
|
265
|
+
children: tbodyRender()
|
|
266
|
+
})]
|
|
259
267
|
})]
|
|
260
|
-
})
|
|
261
|
-
|
|
268
|
+
})
|
|
269
|
+
);
|
|
262
270
|
};
|
|
263
271
|
export default TableBody;
|
|
@@ -10,7 +10,6 @@ table {
|
|
|
10
10
|
background-color: @globalColor0;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
13
|
.tbody-tr,
|
|
15
14
|
.tbody-tr-selected {
|
|
16
15
|
// display: flex;
|
|
@@ -29,22 +28,31 @@ table {
|
|
|
29
28
|
|
|
30
29
|
.tbody-tr-td,
|
|
31
30
|
.tbody-tr-td-drag,
|
|
32
|
-
.tbody-tr-selected
|
|
33
|
-
.tbody-tr-selected
|
|
31
|
+
.tbody-tr-selected > .tbody-tr-td,
|
|
32
|
+
.tbody-tr-selected > .tbody-tr-td-drag {
|
|
34
33
|
background-color: @globalColor0;
|
|
35
34
|
height: 39px;
|
|
36
35
|
line-height: 39px;
|
|
37
|
-
overflow: hidden;
|
|
36
|
+
// overflow: hidden;
|
|
38
37
|
text-overflow: ellipsis;
|
|
39
38
|
white-space: nowrap;
|
|
40
39
|
padding: 0;
|
|
40
|
+
transition: background-color 0.3s;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
.tbody-tr-selected
|
|
44
|
-
.tbody-tr-selected
|
|
43
|
+
.tbody-tr-selected > .tbody-tr-td,
|
|
44
|
+
.tbody-tr-selected > .tbody-tr-td-drag {
|
|
45
45
|
background: @selectTableRow;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
.tbody-tr:not(.tbody-tr-selected) {
|
|
49
|
+
&:hover {
|
|
50
|
+
.tbody-tr-td {
|
|
51
|
+
background-color: @rowHoverBackgroundColor;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
.tbody-tr-td-drag:hover {
|
|
49
57
|
cursor: move;
|
|
50
58
|
}
|
|
@@ -55,7 +63,7 @@ table {
|
|
|
55
63
|
.subRowWrapper {
|
|
56
64
|
padding-left: 40px;
|
|
57
65
|
position: sticky;
|
|
58
|
-
left:
|
|
66
|
+
left: 0;
|
|
59
67
|
overflow: hidden;
|
|
60
68
|
}
|
|
61
69
|
}
|
|
@@ -104,4 +112,31 @@ table {
|
|
|
104
112
|
color: @globalColor2;
|
|
105
113
|
font-size: 12px;
|
|
106
114
|
}
|
|
107
|
-
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.tbody-tr-td-cell-fix-left-last::after {
|
|
118
|
+
box-shadow: inset 10px 0 8px -8px #00000026;
|
|
119
|
+
position: absolute;
|
|
120
|
+
top: 0;
|
|
121
|
+
right: 0;
|
|
122
|
+
bottom: -1px;
|
|
123
|
+
width: 30px;
|
|
124
|
+
transform: translate(100%);
|
|
125
|
+
transition: box-shadow 0.3s;
|
|
126
|
+
content: '';
|
|
127
|
+
pointer-events: none;
|
|
128
|
+
box-sizing: border-box;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.tbody-tr-td-cell-fix-right-first::after {
|
|
132
|
+
box-shadow: inset -10px 0 8px -8px #00000026;
|
|
133
|
+
position: absolute;
|
|
134
|
+
top: 0;
|
|
135
|
+
bottom: -1px;
|
|
136
|
+
left: 0;
|
|
137
|
+
width: 30px;
|
|
138
|
+
transform: translate(-100%);
|
|
139
|
+
transition: box-shadow 0.3s;
|
|
140
|
+
content: '';
|
|
141
|
+
pointer-events: none;
|
|
142
|
+
}
|
|
@@ -21,6 +21,7 @@ import { flexRender } from '@tanstack/react-table';
|
|
|
21
21
|
import { useMemo } from 'react';
|
|
22
22
|
import { useDrag, useDrop } from 'react-dnd';
|
|
23
23
|
import { ColumnType } from "../TableMax";
|
|
24
|
+
import Sort from "../components/ColumnSort";
|
|
24
25
|
import "./index.less";
|
|
25
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
27
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -35,6 +36,7 @@ var Cell = function Cell(_ref) {
|
|
|
35
36
|
canSorting = _ref.canSorting,
|
|
36
37
|
getHeaderCellProps = _ref.getHeaderCellProps,
|
|
37
38
|
columnResizeMode = _ref.columnResizeMode;
|
|
39
|
+
var cannotDragColumn = [ColumnType.Darg, ColumnType.Selection, ColumnType.Expander, ColumnType.PlaceHolder];
|
|
38
40
|
var getState = table.getState,
|
|
39
41
|
setColumnOrder = table.setColumnOrder;
|
|
40
42
|
var _getState = getState(),
|
|
@@ -64,26 +66,6 @@ var Cell = function Cell(_ref) {
|
|
|
64
66
|
_objectDestructuringEmpty(_useDrag2[0]);
|
|
65
67
|
var dragRef = _useDrag2[1],
|
|
66
68
|
previewRef = _useDrag2[2];
|
|
67
|
-
function sortingRender() {
|
|
68
|
-
return {
|
|
69
|
-
asc: /*#__PURE__*/_jsxs("span", {
|
|
70
|
-
className: "sort-flag",
|
|
71
|
-
children: [/*#__PURE__*/_jsx("i", {
|
|
72
|
-
className: "triangle-up triangle-up-red"
|
|
73
|
-
}), /*#__PURE__*/_jsx("i", {
|
|
74
|
-
className: "triangle-down"
|
|
75
|
-
})]
|
|
76
|
-
}),
|
|
77
|
-
desc: /*#__PURE__*/_jsxs("span", {
|
|
78
|
-
className: "sort-flag",
|
|
79
|
-
children: [/*#__PURE__*/_jsx("i", {
|
|
80
|
-
className: "triangle-up"
|
|
81
|
-
}), /*#__PURE__*/_jsx("i", {
|
|
82
|
-
className: "triangle-down triangle-down-red"
|
|
83
|
-
})]
|
|
84
|
-
})
|
|
85
|
-
}[header.column.getIsSorted()];
|
|
86
|
-
}
|
|
87
69
|
var columnDef = useMemo(function () {
|
|
88
70
|
return header.column.columnDef;
|
|
89
71
|
}, [header]);
|
|
@@ -118,11 +100,13 @@ var Cell = function Cell(_ref) {
|
|
|
118
100
|
})
|
|
119
101
|
}) :
|
|
120
102
|
// @ts-ignore
|
|
121
|
-
flexRender(columnDef.header, header.getContext()), canSorting ?
|
|
103
|
+
flexRender(columnDef.header, header.getContext()), canSorting ? /*#__PURE__*/_jsx(Sort, {
|
|
104
|
+
sort: header.column.getIsSorted()
|
|
105
|
+
}) : null]
|
|
122
106
|
}), /*#__PURE__*/_jsx("div", {
|
|
123
107
|
className: "cell-right",
|
|
124
108
|
onClick: header.column.getToggleSortingHandler(),
|
|
125
|
-
children:
|
|
109
|
+
children: cannotDragColumn.includes(header.column.id) || header.column.getIsPinned() ? null : /*#__PURE__*/_jsx("i", {
|
|
126
110
|
ref: dragRef,
|
|
127
111
|
className: "icon iconfont-other icon-other-drag drag-handler"
|
|
128
112
|
})
|
|
@@ -12,6 +12,10 @@ type TableHeaderProps = {
|
|
|
12
12
|
hasVerticalScrollBar: boolean;
|
|
13
13
|
getHeaderCellProps?: (columns: TableMaxColumnType[]) => object;
|
|
14
14
|
columnResizeMode: ColumnResizeMode;
|
|
15
|
+
pinShadowVisible: {
|
|
16
|
+
left: boolean;
|
|
17
|
+
right: boolean;
|
|
18
|
+
};
|
|
15
19
|
};
|
|
16
|
-
declare const TableHeader: ({ table, headerGroups, canFilter, enableFilters, canSorting, hasGroup, hasVerticalScrollBar, getHeaderCellProps, columnResizeMode, }: TableHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare const TableHeader: ({ table, headerGroups, canFilter, enableFilters, canSorting, hasGroup, hasVerticalScrollBar, getHeaderCellProps, columnResizeMode, pinShadowVisible, }: TableHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
21
|
export default TableHeader;
|
|
@@ -9,6 +9,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
9
9
|
|
|
10
10
|
import { useEffect, useMemo } from 'react';
|
|
11
11
|
import { Filter } from "../components/ColumnFilter";
|
|
12
|
+
import { getShadowInfo } from "../utils";
|
|
12
13
|
import Cell from "./Cell";
|
|
13
14
|
import "./index.less";
|
|
14
15
|
import { getPinningStyle } from "./utils";
|
|
@@ -24,7 +25,8 @@ var TableHeader = function TableHeader(_ref) {
|
|
|
24
25
|
hasGroup = _ref.hasGroup,
|
|
25
26
|
hasVerticalScrollBar = _ref.hasVerticalScrollBar,
|
|
26
27
|
getHeaderCellProps = _ref.getHeaderCellProps,
|
|
27
|
-
columnResizeMode = _ref.columnResizeMode
|
|
28
|
+
columnResizeMode = _ref.columnResizeMode,
|
|
29
|
+
pinShadowVisible = _ref.pinShadowVisible;
|
|
28
30
|
var hasPinning = useMemo(function () {
|
|
29
31
|
var columnPinning = table.getState().columnPinning;
|
|
30
32
|
console.log(44445555, JSON.stringify(columnPinning.left) !== '[]', JSON.stringify(columnPinning.right) !== '[]');
|
|
@@ -55,9 +57,6 @@ var TableHeader = function TableHeader(_ref) {
|
|
|
55
57
|
// );
|
|
56
58
|
|
|
57
59
|
return /*#__PURE__*/_jsxs("table", {
|
|
58
|
-
style: {
|
|
59
|
-
width: table.getTotalSize() + hasVerticalScrollBar ? 10 : 0
|
|
60
|
-
},
|
|
61
60
|
children: [/*#__PURE__*/_jsxs("colgroup", {
|
|
62
61
|
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) {
|
|
63
62
|
return /*#__PURE__*/_jsx("col", {
|
|
@@ -75,9 +74,14 @@ var TableHeader = function TableHeader(_ref) {
|
|
|
75
74
|
width: '100%'
|
|
76
75
|
},
|
|
77
76
|
children: [headerGroup.headers.map(function (header) {
|
|
77
|
+
// 列固定时的阴影判断逻辑
|
|
78
|
+
var _getShadowInfo = getShadowInfo(header.column, table),
|
|
79
|
+
isRightFirst = _getShadowInfo.isRightFirst,
|
|
80
|
+
isLeftLast = _getShadowInfo.isLeftLast;
|
|
78
81
|
return /*#__PURE__*/_jsx("th", {
|
|
79
82
|
colSpan: header.colSpan,
|
|
80
83
|
style: _objectSpread({}, getPinningStyle(header, table, hasVerticalScrollBar)),
|
|
84
|
+
className: "".concat(isLeftLast && pinShadowVisible.left ? 'thead-tr-th-cell-fix-left-last' : '', " ").concat(isRightFirst && pinShadowVisible.right ? 'thead-tr-th-cell-fix-right-first' : ''),
|
|
81
85
|
children: header.isPlaceholder ? null : /*#__PURE__*/_jsx(Cell, {
|
|
82
86
|
header: header,
|
|
83
87
|
table: table,
|
|
@@ -94,9 +98,13 @@ var TableHeader = function TableHeader(_ref) {
|
|
|
94
98
|
}), canFilter && enableFilters ? /*#__PURE__*/_jsxs("tr", {
|
|
95
99
|
className: "table-filter-tr",
|
|
96
100
|
children: [headerGroups === null || headerGroups === void 0 || (_headerGroups2 = headerGroups[headerGroups.length - 1]) === null || _headerGroups2 === void 0 || (_headerGroups2 = _headerGroups2.headers) === null || _headerGroups2 === void 0 ? void 0 : _headerGroups2.map(function (header) {
|
|
101
|
+
// 列固定时的阴影判断逻辑
|
|
102
|
+
var _getShadowInfo2 = getShadowInfo(header.column, table),
|
|
103
|
+
isRightFirst = _getShadowInfo2.isRightFirst,
|
|
104
|
+
isLeftLast = _getShadowInfo2.isLeftLast;
|
|
97
105
|
return /*#__PURE__*/_jsx("th", {
|
|
98
|
-
className: "table-filter-th",
|
|
99
106
|
style: _objectSpread({}, getPinningStyle(header, table, hasVerticalScrollBar)),
|
|
107
|
+
className: "table-filter-th ".concat(isLeftLast && pinShadowVisible.left ? 'thead-tr-th-cell-fix-left-last' : '', " ").concat(isRightFirst && pinShadowVisible.right ? 'thead-tr-th-cell-fix-right-first' : ''),
|
|
100
108
|
children: header.column.getCanFilter() ? /*#__PURE__*/_jsx("div", {
|
|
101
109
|
children: /*#__PURE__*/_jsx(Filter, {
|
|
102
110
|
column: header.column
|
|
@@ -61,40 +61,6 @@ table {
|
|
|
61
61
|
// opacity: 1;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
.sort-flag {
|
|
65
|
-
display: inline-block;
|
|
66
|
-
vertical-align: middle;
|
|
67
|
-
margin-left: 6px;
|
|
68
|
-
margin-right: 20px;
|
|
69
|
-
|
|
70
|
-
.triangle-up {
|
|
71
|
-
display: block;
|
|
72
|
-
width: 0;
|
|
73
|
-
height: 0;
|
|
74
|
-
border-left: 4px solid transparent;
|
|
75
|
-
border-right: 4px solid transparent;
|
|
76
|
-
border-bottom: 6px solid #b4b6bfff;
|
|
77
|
-
|
|
78
|
-
&-red {
|
|
79
|
-
border-bottom: 6px solid #fa541cff;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.triangle-down {
|
|
84
|
-
display: block;
|
|
85
|
-
width: 0;
|
|
86
|
-
height: 0;
|
|
87
|
-
margin-top: 3px;
|
|
88
|
-
border-left: 4px solid transparent;
|
|
89
|
-
border-right: 4px solid transparent;
|
|
90
|
-
border-top: 6px solid #b4b6bfff;
|
|
91
|
-
|
|
92
|
-
&-red {
|
|
93
|
-
border-top: 6px solid #fa541cff;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
64
|
.cell-resize-handler {
|
|
99
65
|
position: absolute;
|
|
100
66
|
right: 0;
|
|
@@ -126,13 +92,40 @@ table {
|
|
|
126
92
|
}
|
|
127
93
|
}
|
|
128
94
|
|
|
95
|
+
.thead-tr-th-cell-fix-left-last::after {
|
|
96
|
+
box-shadow: inset 10px 0 8px -8px #00000026;
|
|
97
|
+
position: absolute;
|
|
98
|
+
top: 0;
|
|
99
|
+
right: 0;
|
|
100
|
+
bottom: -1px;
|
|
101
|
+
width: 30px;
|
|
102
|
+
transform: translate(100%);
|
|
103
|
+
transition: box-shadow 0.3s;
|
|
104
|
+
content: '';
|
|
105
|
+
pointer-events: none;
|
|
106
|
+
box-sizing: border-box;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.thead-tr-th-cell-fix-right-first::after {
|
|
110
|
+
box-shadow: inset -10px 0 8px -8px #00000026;
|
|
111
|
+
position: absolute;
|
|
112
|
+
top: 0;
|
|
113
|
+
bottom: -1px;
|
|
114
|
+
left: 0;
|
|
115
|
+
width: 30px;
|
|
116
|
+
transform: translate(-100%);
|
|
117
|
+
transition: box-shadow 0.3s;
|
|
118
|
+
content: '';
|
|
119
|
+
pointer-events: none;
|
|
120
|
+
}
|
|
121
|
+
|
|
129
122
|
.table-filter-tr {
|
|
130
123
|
border-top: 1px solid @tableColor2;
|
|
131
124
|
|
|
132
125
|
.table-filter-th {
|
|
133
126
|
text-align: center;
|
|
134
127
|
vertical-align: top;
|
|
135
|
-
padding: 6px
|
|
128
|
+
padding: 6px 4px;
|
|
136
129
|
|
|
137
130
|
.custom-light-select:not(.custom-light-select-customize-input) .custom-light-select-selector {
|
|
138
131
|
border-radius: 2px;
|
|
@@ -1,9 +1,37 @@
|
|
|
1
|
+
var getOffsetLeft = function getOffsetLeft(list, column, visibleColumnSizesMap) {
|
|
2
|
+
var x = 0;
|
|
3
|
+
for (var i = 0; i < list.length; i++) {
|
|
4
|
+
var curr = list[i];
|
|
5
|
+
if (curr === column.id) {
|
|
6
|
+
return x;
|
|
7
|
+
}
|
|
8
|
+
x += visibleColumnSizesMap[curr] || 0;
|
|
9
|
+
}
|
|
10
|
+
return x;
|
|
11
|
+
};
|
|
12
|
+
var getOffsetRight = function getOffsetRight(list, column, visibleColumnSizesMap) {
|
|
13
|
+
var x = 0;
|
|
14
|
+
for (var i = list.length - 1; i > 0; i--) {
|
|
15
|
+
var curr = list[i];
|
|
16
|
+
if (curr === column.id) {
|
|
17
|
+
return x;
|
|
18
|
+
}
|
|
19
|
+
x += visibleColumnSizesMap[curr] || 0;
|
|
20
|
+
}
|
|
21
|
+
return x;
|
|
22
|
+
};
|
|
1
23
|
export var getPinningStyle = function getPinningStyle(header, table, hasVerticalScrollBar) {
|
|
24
|
+
var _table$getVisibleLeaf;
|
|
2
25
|
var column = header.column;
|
|
3
|
-
var visibleColumnSizes = table.
|
|
26
|
+
var visibleColumnSizes = (_table$getVisibleLeaf = table.getVisibleLeafColumns()) === null || _table$getVisibleLeaf === void 0 ? void 0 : _table$getVisibleLeaf.map(function (item) {
|
|
27
|
+
return {
|
|
28
|
+
id: item.id,
|
|
29
|
+
size: item.getSize()
|
|
30
|
+
};
|
|
31
|
+
});
|
|
4
32
|
var columnPinning = table.getState().columnPinning;
|
|
5
33
|
var visibleColumnSizesMap = {};
|
|
6
|
-
visibleColumnSizes.
|
|
34
|
+
visibleColumnSizes.forEach(function (item) {
|
|
7
35
|
visibleColumnSizesMap[item === null || item === void 0 ? void 0 : item.id] = item.size;
|
|
8
36
|
});
|
|
9
37
|
switch (column.getIsPinned()) {
|
|
@@ -36,26 +64,4 @@ export var getPinningStyle = function getPinningStyle(header, table, hasVertical
|
|
|
36
64
|
// width: column.getSize(),
|
|
37
65
|
};
|
|
38
66
|
}
|
|
39
|
-
};
|
|
40
|
-
var getOffsetLeft = function getOffsetLeft(list, column, visibleColumnSizesMap) {
|
|
41
|
-
var x = 0;
|
|
42
|
-
for (var i = 0; i < list.length; i++) {
|
|
43
|
-
var curr = list[i];
|
|
44
|
-
if (curr === column.id) {
|
|
45
|
-
return x;
|
|
46
|
-
}
|
|
47
|
-
x += visibleColumnSizesMap[curr] || 0;
|
|
48
|
-
}
|
|
49
|
-
return x;
|
|
50
|
-
};
|
|
51
|
-
var getOffsetRight = function getOffsetRight(list, column, visibleColumnSizesMap) {
|
|
52
|
-
var x = 0;
|
|
53
|
-
for (var i = list.length - 1; i > 0; i--) {
|
|
54
|
-
var curr = list[i];
|
|
55
|
-
if (curr === column.id) {
|
|
56
|
-
return x;
|
|
57
|
-
}
|
|
58
|
-
x += visibleColumnSizesMap[curr] || 0;
|
|
59
|
-
}
|
|
60
|
-
return x;
|
|
61
67
|
};
|
|
@@ -13,6 +13,7 @@ export declare enum ColumnType {
|
|
|
13
13
|
PlaceHolder = "placeholder-column",
|
|
14
14
|
Expander = "expander"
|
|
15
15
|
}
|
|
16
|
+
export type ColumnSizing = Record<string, number>;
|
|
16
17
|
export declare const TableContext: React.Context<TableContextType>;
|
|
17
18
|
declare const _default: React.ForwardRefExoticComponent<TableMaxProps & React.RefAttributes<unknown>>;
|
|
18
19
|
export default _default;
|