@arim-aisdc/public-components 2.3.16 → 2.3.18
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/CenterModal/CenterModal.d.ts +2 -2
- package/dist/components/CenterModal/CenterModal.js +70 -90
- package/dist/components/CenterModal/index.less +88 -0
- package/dist/components/CenterModal/type.d.ts +8 -0
- package/dist/components/CustomForm/CustomForm.js +5 -1
- package/dist/components/TableMax/TableBody/components/Total.d.ts +7 -0
- package/dist/components/TableMax/TableBody/components/Total.js +63 -0
- package/dist/components/TableMax/TableBody/index.d.ts +4 -1
- package/dist/components/TableMax/TableBody/index.js +20 -7
- package/dist/components/TableMax/TableBody/index.less +8 -4
- package/dist/components/TableMax/TableHeader/Cell.js +16 -32
- package/dist/components/TableMax/TableHeader/index.less +31 -8
- package/dist/components/TableMax/TableMax.js +9 -9
- package/dist/components/TableMax/components/ColumnSort/customSortFns.d.ts +8 -8
- package/dist/components/TableMax/hooks/useColumnResize.d.ts +9 -0
- package/dist/components/TableMax/hooks/useColumnResize.js +162 -0
- package/dist/components/TableMax/hooks/useColumnWidth copy.d.ts +18 -0
- package/dist/components/TableMax/hooks/useColumnWidth copy.js +369 -0
- package/dist/components/TableMax/hooks/useColumnWidth.d.ts +7 -3
- package/dist/components/TableMax/hooks/useColumnWidth.js +218 -283
- package/dist/components/TableMax/type.d.ts +4 -0
- package/package.json +4 -1
|
@@ -42,6 +42,7 @@ table {
|
|
|
42
42
|
display: flex;
|
|
43
43
|
align-items: center;
|
|
44
44
|
justify-content: space-between;
|
|
45
|
+
height: 100%;
|
|
45
46
|
|
|
46
47
|
.cell-left-header {
|
|
47
48
|
display: -webkit-box;
|
|
@@ -76,6 +77,14 @@ table {
|
|
|
76
77
|
display: inline-block;
|
|
77
78
|
// opacity: 1;
|
|
78
79
|
}
|
|
80
|
+
&:hover {
|
|
81
|
+
.sort-flag {
|
|
82
|
+
display: flex;
|
|
83
|
+
}
|
|
84
|
+
.filter-icon {
|
|
85
|
+
display: inline-block;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
79
88
|
|
|
80
89
|
.cell-resize-handler {
|
|
81
90
|
position: absolute;
|
|
@@ -95,22 +104,29 @@ table {
|
|
|
95
104
|
top: 0%;
|
|
96
105
|
height: 100%;
|
|
97
106
|
z-index: 99999;
|
|
107
|
+
cursor: ew-resize;
|
|
98
108
|
}
|
|
99
109
|
}
|
|
100
110
|
|
|
111
|
+
.cell-resize-handler::after {
|
|
112
|
+
content: '';
|
|
113
|
+
position: absolute;
|
|
114
|
+
right: 0;
|
|
115
|
+
top: 0;
|
|
116
|
+
bottom: 0;
|
|
117
|
+
width: 5px;
|
|
118
|
+
cursor: ew-resize;
|
|
119
|
+
}
|
|
120
|
+
|
|
101
121
|
.column-resizer.column-is-resizing {
|
|
102
122
|
height: 60%;
|
|
103
123
|
top: 20%;
|
|
104
124
|
}
|
|
105
125
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
.filter-icon {
|
|
111
|
-
display: inline-block;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
114
130
|
}
|
|
115
131
|
|
|
116
132
|
.table-thead-tr:nth-last-child(2) {
|
|
@@ -227,3 +243,10 @@ table {
|
|
|
227
243
|
// background-color: #000;
|
|
228
244
|
background-color: green;
|
|
229
245
|
}
|
|
246
|
+
.column-resizing-divide-line {
|
|
247
|
+
will-change: transform;
|
|
248
|
+
backface-visibility: hidden;
|
|
249
|
+
transform: translate3d(0, 0, 0);
|
|
250
|
+
contain: strict;
|
|
251
|
+
cursor: ew-resize;
|
|
252
|
+
}
|
|
@@ -26,7 +26,7 @@ import dayjs from 'dayjs';
|
|
|
26
26
|
import { cloneDeep, debounce } from 'lodash';
|
|
27
27
|
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
28
28
|
import { useConfig } from "../ConfigProvider";
|
|
29
|
-
import TableBody from "./TableBody";
|
|
29
|
+
import TableBody, { MemoizedTableBody } from "./TableBody";
|
|
30
30
|
import TableHeader from "./TableHeader";
|
|
31
31
|
import { InputType } from "./components/ColumnEdit";
|
|
32
32
|
import { setDefaultFilterFn } from "./components/ColumnFilterV2";
|
|
@@ -140,7 +140,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
140
140
|
getCellProps = _ref.getCellProps,
|
|
141
141
|
getHeaderCellProps = _ref.getHeaderCellProps,
|
|
142
142
|
_ref$rowHeight = _ref.rowHeight,
|
|
143
|
-
rowHeight = _ref$rowHeight === void 0 ?
|
|
143
|
+
rowHeight = _ref$rowHeight === void 0 ? 42 : _ref$rowHeight,
|
|
144
144
|
_ref$defaultColumnFil = _ref.defaultColumnFilters,
|
|
145
145
|
defaultColumnFilters = _ref$defaultColumnFil === void 0 ? [] : _ref$defaultColumnFil,
|
|
146
146
|
getColumnFiltersData = _ref.getColumnFiltersData,
|
|
@@ -185,7 +185,9 @@ var TableMax = function TableMax(_ref) {
|
|
|
185
185
|
_ref$disableColumnDra = _ref.disableColumnDrag,
|
|
186
186
|
disableColumnDrag = _ref$disableColumnDra === void 0 ? false : _ref$disableColumnDra,
|
|
187
187
|
request = _ref.request,
|
|
188
|
-
onEditValueChange = _ref.onEditValueChange
|
|
188
|
+
onEditValueChange = _ref.onEditValueChange,
|
|
189
|
+
hasTotalRow = _ref.hasTotalRow,
|
|
190
|
+
totalDatas = _ref.totalDatas;
|
|
189
191
|
var tableMaxRef = useRef(null);
|
|
190
192
|
// 表格元素
|
|
191
193
|
var tableContentRef = useRef(null);
|
|
@@ -965,10 +967,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
965
967
|
getPinShadowInfo();
|
|
966
968
|
}, [getPinShadowInfo]);
|
|
967
969
|
|
|
968
|
-
// useEffect(() => {
|
|
969
|
-
// console.log(table.getState().columnSizing, 111);
|
|
970
|
-
// }, [table.getState().columnSizing]);
|
|
971
|
-
|
|
972
970
|
// 获取展示阴影的列
|
|
973
971
|
var shadowColumnInfo = useMemo(function () {
|
|
974
972
|
var _pop, _shift;
|
|
@@ -1046,7 +1044,9 @@ var TableMax = function TableMax(_ref) {
|
|
|
1046
1044
|
getRowHoverTipConfig: getRowHoverTipConfig,
|
|
1047
1045
|
tableTooltip: tableTooltip,
|
|
1048
1046
|
compactMode: compactMode,
|
|
1049
|
-
onEditValueChange: onEditValueChange
|
|
1047
|
+
onEditValueChange: onEditValueChange,
|
|
1048
|
+
hasTotalRow: hasTotalRow,
|
|
1049
|
+
totalDatas: totalDatas
|
|
1050
1050
|
};
|
|
1051
1051
|
var changeCompactMode = function changeCompactMode() {
|
|
1052
1052
|
setCompactMode(!compactMode);
|
|
@@ -1198,7 +1198,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
1198
1198
|
style: {
|
|
1199
1199
|
width: "100%"
|
|
1200
1200
|
},
|
|
1201
|
-
children: /*#__PURE__*/_jsx(TableBody, _objectSpread({}, tableBodyProps))
|
|
1201
|
+
children: table.getState().columnSizingInfo.isResizingColumn ? /*#__PURE__*/_jsx(MemoizedTableBody, _objectSpread({}, tableBodyProps)) : /*#__PURE__*/_jsx(TableBody, _objectSpread({}, tableBodyProps))
|
|
1202
1202
|
})]
|
|
1203
1203
|
})
|
|
1204
1204
|
}), pagination && /*#__PURE__*/_jsx("div", {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { TableMaxColumnType } from "../../type";
|
|
2
|
-
export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
3
|
-
export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
4
|
-
export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
5
|
-
export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
2
|
+
export declare const numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
3
|
+
export declare const stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
4
|
+
export declare const numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
5
|
+
export declare const timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
6
6
|
declare const customSortFns: {
|
|
7
|
-
numberSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
8
|
-
stringSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
9
|
-
timeSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
10
|
-
numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) =>
|
|
7
|
+
numberSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
8
|
+
stringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
9
|
+
timeSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
10
|
+
numberOrStringSortFn: (rowA: any, rowB: any, columnId: string) => 0 | 1 | -1;
|
|
11
11
|
};
|
|
12
12
|
export default customSortFns;
|
|
13
13
|
export type SortFnType = keyof typeof customSortFns | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Header, Table } from '@tanstack/react-table';
|
|
2
|
+
export declare const useColumnResize: <T>({ header, table, tableContentRef, rootContainer }: {
|
|
3
|
+
header: Header<T, unknown>;
|
|
4
|
+
table: Table<T>;
|
|
5
|
+
tableContentRef: React.RefObject<HTMLDivElement>;
|
|
6
|
+
rootContainer?: string;
|
|
7
|
+
}) => {
|
|
8
|
+
handleResizeStart: (e: React.MouseEvent) => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
// hooks/useColumnResize.ts
|
|
8
|
+
import { useEffect, useRef, useCallback } from 'react';
|
|
9
|
+
export var useColumnResize = function useColumnResize(_ref) {
|
|
10
|
+
var header = _ref.header,
|
|
11
|
+
table = _ref.table,
|
|
12
|
+
tableContentRef = _ref.tableContentRef,
|
|
13
|
+
rootContainer = _ref.rootContainer;
|
|
14
|
+
// DOM元素引用
|
|
15
|
+
var resizeLineRef = useRef(null);
|
|
16
|
+
var overlayRef = useRef(null);
|
|
17
|
+
|
|
18
|
+
// 状态和位置引用
|
|
19
|
+
var isResizingRef = useRef(false);
|
|
20
|
+
var startXRef = useRef(0);
|
|
21
|
+
var startWidthRef = useRef(0);
|
|
22
|
+
var containerHeightRef = useRef(0);
|
|
23
|
+
var rafIdRef = useRef(0);
|
|
24
|
+
var lastClientXRef = useRef(0); // 新增:记录最后的位置
|
|
25
|
+
|
|
26
|
+
// 初始化创建DOM元素
|
|
27
|
+
useEffect(function () {
|
|
28
|
+
var container = rootContainer ? document.querySelector(rootContainer) : document.body;
|
|
29
|
+
if (!container) return;
|
|
30
|
+
|
|
31
|
+
// 创建分割线
|
|
32
|
+
var resizeLine = document.createElement('div');
|
|
33
|
+
resizeLine.className = 'column-resizing-divide-line';
|
|
34
|
+
Object.assign(resizeLine.style, {
|
|
35
|
+
position: 'fixed',
|
|
36
|
+
pointerEvents: 'none',
|
|
37
|
+
zIndex: '1000',
|
|
38
|
+
display: 'none',
|
|
39
|
+
width: '1px',
|
|
40
|
+
backgroundColor: '#1890ff',
|
|
41
|
+
willChange: 'transform',
|
|
42
|
+
transition: 'none',
|
|
43
|
+
top: '0',
|
|
44
|
+
height: '0',
|
|
45
|
+
transform: 'translate3d(0,0,0)'
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// 创建遮罩层
|
|
49
|
+
var overlay = document.createElement('div');
|
|
50
|
+
overlay.className = 'column-resize-overlay';
|
|
51
|
+
Object.assign(overlay.style, {
|
|
52
|
+
position: 'fixed',
|
|
53
|
+
top: '0',
|
|
54
|
+
left: '0',
|
|
55
|
+
width: '100vw',
|
|
56
|
+
height: '100vh',
|
|
57
|
+
zIndex: '9998',
|
|
58
|
+
cursor: 'ew-resize',
|
|
59
|
+
display: 'none',
|
|
60
|
+
pointerEvents: 'auto',
|
|
61
|
+
backgroundColor: 'transparent'
|
|
62
|
+
});
|
|
63
|
+
container.appendChild(resizeLine);
|
|
64
|
+
container.appendChild(overlay);
|
|
65
|
+
resizeLineRef.current = resizeLine;
|
|
66
|
+
overlayRef.current = overlay;
|
|
67
|
+
return function () {
|
|
68
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
69
|
+
if (resizeLine.parentNode) container.removeChild(resizeLine);
|
|
70
|
+
if (overlay.parentNode) container.removeChild(overlay);
|
|
71
|
+
};
|
|
72
|
+
}, [rootContainer]);
|
|
73
|
+
|
|
74
|
+
// 更新分割线位置
|
|
75
|
+
var updateResizeLinePosition = useCallback(function (x, height) {
|
|
76
|
+
if (!resizeLineRef.current) return;
|
|
77
|
+
lastClientXRef.current = x; // 更新最后的位置
|
|
78
|
+
resizeLineRef.current.style.transform = "translate3d(".concat(x, "px, 0, 0)");
|
|
79
|
+
resizeLineRef.current.style.height = "".concat(height, "px");
|
|
80
|
+
}, []);
|
|
81
|
+
|
|
82
|
+
// 处理拖动开始
|
|
83
|
+
var handleResizeStart = useCallback(function (e) {
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
var elem = tableContentRef.current;
|
|
87
|
+
var clientRect = elem === null || elem === void 0 ? void 0 : elem.getBoundingClientRect();
|
|
88
|
+
var containerTop = (clientRect === null || clientRect === void 0 ? void 0 : clientRect.top) || 0;
|
|
89
|
+
var containerHeight = (clientRect === null || clientRect === void 0 ? void 0 : clientRect.height) || 0;
|
|
90
|
+
|
|
91
|
+
// 设置初始状态
|
|
92
|
+
isResizingRef.current = true;
|
|
93
|
+
startXRef.current = e.clientX;
|
|
94
|
+
startWidthRef.current = header.column.getSize();
|
|
95
|
+
containerHeightRef.current = containerHeight;
|
|
96
|
+
lastClientXRef.current = e.clientX;
|
|
97
|
+
|
|
98
|
+
// 显示并定位元素
|
|
99
|
+
if (resizeLineRef.current) {
|
|
100
|
+
resizeLineRef.current.style.top = "".concat(containerTop, "px");
|
|
101
|
+
resizeLineRef.current.style.display = 'block';
|
|
102
|
+
updateResizeLinePosition(e.clientX, containerHeight);
|
|
103
|
+
}
|
|
104
|
+
if (overlayRef.current) {
|
|
105
|
+
overlayRef.current.style.display = 'block';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// 设置全局样式
|
|
109
|
+
document.body.classList.add('column-resizing');
|
|
110
|
+
document.body.style.cursor = 'ew-resize';
|
|
111
|
+
document.body.style.userSelect = 'none';
|
|
112
|
+
|
|
113
|
+
// 移动处理函数
|
|
114
|
+
var onMove = function onMove(moveEvent) {
|
|
115
|
+
if (!isResizingRef.current) return;
|
|
116
|
+
rafIdRef.current = requestAnimationFrame(function () {
|
|
117
|
+
updateResizeLinePosition(moveEvent.clientX, containerHeight);
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// 结束处理函数
|
|
122
|
+
var onEnd = function onEnd() {
|
|
123
|
+
if (!isResizingRef.current) return;
|
|
124
|
+
cancelAnimationFrame(rafIdRef.current);
|
|
125
|
+
|
|
126
|
+
// 立即更新列宽(关键修改点)
|
|
127
|
+
var finalDelta = lastClientXRef.current - startXRef.current;
|
|
128
|
+
var newWidth = Math.max(20, startWidthRef.current + finalDelta);
|
|
129
|
+
table.setColumnSizing(function (old) {
|
|
130
|
+
return _objectSpread(_objectSpread({}, old), {}, _defineProperty({}, header.column.id, newWidth));
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// 隐藏元素
|
|
134
|
+
if (resizeLineRef.current) {
|
|
135
|
+
resizeLineRef.current.style.display = 'none';
|
|
136
|
+
}
|
|
137
|
+
if (overlayRef.current) {
|
|
138
|
+
overlayRef.current.style.display = 'none';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// 恢复全局样式
|
|
142
|
+
document.body.classList.remove('column-resizing');
|
|
143
|
+
document.body.style.cursor = '';
|
|
144
|
+
document.body.style.userSelect = '';
|
|
145
|
+
isResizingRef.current = false;
|
|
146
|
+
document.removeEventListener('mousemove', onMove);
|
|
147
|
+
document.removeEventListener('mouseup', onEnd);
|
|
148
|
+
};
|
|
149
|
+
document.addEventListener('mousemove', onMove, {
|
|
150
|
+
passive: true
|
|
151
|
+
});
|
|
152
|
+
document.addEventListener('mouseup', onEnd, {
|
|
153
|
+
once: true
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// 调用原始处理程序
|
|
157
|
+
header.getResizeHandler()(e);
|
|
158
|
+
}, [header, table, tableContentRef, updateResizeLinePosition]);
|
|
159
|
+
return {
|
|
160
|
+
handleResizeStart: handleResizeStart
|
|
161
|
+
};
|
|
162
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ColumnSizing } from '../TableMax';
|
|
3
|
+
interface UseColumnWidthProps {
|
|
4
|
+
tableContentRef: React.RefObject<HTMLDivElement>;
|
|
5
|
+
tableId: string;
|
|
6
|
+
tableKeyPrefixCls: string;
|
|
7
|
+
columnVisibleConfig?: Record<string, boolean>;
|
|
8
|
+
tableKey: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const useColumnWidth: ({ tableContentRef, tableId, tableKeyPrefixCls, columnVisibleConfig, tableKey, }: UseColumnWidthProps) => {
|
|
11
|
+
columnSizing: ColumnSizing;
|
|
12
|
+
allColumnCount: number;
|
|
13
|
+
onColumnSizingChange: (data: any) => void;
|
|
14
|
+
tableContainerWidth: number;
|
|
15
|
+
initializeColumnSizing: (columns: any) => void;
|
|
16
|
+
handleVisibleConfigChange: (key: any, value: any) => void;
|
|
17
|
+
};
|
|
18
|
+
export {};
|