@arim-aisdc/public-components 2.3.38 → 2.3.40
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/assets/iconfont/table/iconfont.css +9 -1
- package/dist/assets/iconfont/table/iconfont.ttf +0 -0
- package/dist/components/CustomForm/CustomForm.js +11 -11
- package/dist/components/TableMax/TableBody/Row.d.ts +1 -5
- package/dist/components/TableMax/TableBody/Row.js +3 -6
- package/dist/components/TableMax/TableBody/Row1.d.ts +1 -5
- package/dist/components/TableMax/TableBody/Row1.js +1 -4
- package/dist/components/TableMax/TableBody/components/Total.d.ts +1 -2
- package/dist/components/TableMax/TableBody/components/Total.js +1 -4
- package/dist/components/TableMax/TableBody/index.d.ts +1 -5
- package/dist/components/TableMax/TableBody/index.js +0 -4
- package/dist/components/TableMax/TableBody/index.less +0 -27
- package/dist/components/TableMax/TableHeader/Cell.d.ts +2 -1
- package/dist/components/TableMax/TableHeader/Cell.js +4 -2
- package/dist/components/TableMax/TableHeader/index.d.ts +2 -5
- package/dist/components/TableMax/TableHeader/index.js +20 -7
- package/dist/components/TableMax/TableHeader/index.less +2 -29
- package/dist/components/TableMax/TableHeader/utils.js +12 -4
- package/dist/components/TableMax/TableMax.js +81 -81
- package/dist/components/TableMax/components/ColumnFilterV2/Filter.d.ts +1 -0
- package/dist/components/TableMax/components/ColumnFilterV2/Filter.js +77 -14
- package/dist/components/TableMax/components/ColumnFilterV2/index.d.ts +3 -1
- package/dist/components/TableMax/components/ColumnFilterV2/index.js +19 -3
- package/dist/components/TableMax/components/ColumnSetting/index.js +7 -3
- package/dist/components/TableMax/hooks/useColumnResize.js +6 -4
- package/dist/components/TableMax/hooks/useColumnWidth.js +3 -2
- package/dist/components/TableMax/hooks/useInfiniteScroll.d.ts +28 -0
- package/dist/components/TableMax/hooks/useInfiniteScroll.js +95 -0
- package/dist/components/TableMax/hooks/useTableScrollShadow.d.ts +14 -0
- package/dist/components/TableMax/hooks/useTableScrollShadow.js +106 -0
- package/dist/components/TableMax/tableMax.less +69 -1
- package/dist/components/TableMax/type.d.ts +12 -0
- package/dist/components/TableMax/utils.d.ts +1 -0
- package/dist/components/TableMax/utils.js +13 -1
- package/package.json +1 -1
|
@@ -21,7 +21,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
21
21
|
import { MinusSquareOutlined, PlusSquareOutlined } from '@ant-design/icons';
|
|
22
22
|
import { getCoreRowModel, getExpandedRowModel, getFacetedUniqueValues, getFilteredRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
|
|
23
23
|
import { useUpdateEffect } from 'ahooks';
|
|
24
|
-
import { Button, Checkbox, Form, Pagination, Upload } from 'antd';
|
|
24
|
+
import { Button, Checkbox, Form, Pagination, Tooltip, Upload } from 'antd';
|
|
25
25
|
import dayjs from 'dayjs';
|
|
26
26
|
import { cloneDeep, debounce } from 'lodash';
|
|
27
27
|
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
@@ -38,6 +38,7 @@ import PaginationV2 from "./components/PaginationV2";
|
|
|
38
38
|
import { useColumnWidth } from "./hooks/useColumnWidth";
|
|
39
39
|
import "./tableMax.less";
|
|
40
40
|
import { downloadExcel, getFormatFilters, getFormatFiltersV2, getFormatSorting, operationColumnNoTooltips } from "./utils";
|
|
41
|
+
import { useTableScrollShadow } from "./hooks/useTableScrollShadow";
|
|
41
42
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
42
43
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
43
44
|
export var ColumnType = /*#__PURE__*/function (ColumnType) {
|
|
@@ -62,7 +63,7 @@ var defaultColumnPinningConfig = {
|
|
|
62
63
|
var initSelectedRowIds = [];
|
|
63
64
|
var initColumnFilters = [];
|
|
64
65
|
var TableMax = function TableMax(_ref) {
|
|
65
|
-
var _JSON$parse
|
|
66
|
+
var _JSON$parse;
|
|
66
67
|
var tableId = _ref.tableId,
|
|
67
68
|
originColumns = _ref.columns,
|
|
68
69
|
_ref$datas = _ref.datas,
|
|
@@ -194,7 +195,8 @@ var TableMax = function TableMax(_ref) {
|
|
|
194
195
|
hasTotalRow = _ref.hasTotalRow,
|
|
195
196
|
totalDatas = _ref.totalDatas,
|
|
196
197
|
pageSizeOptions = _ref.pageSizeOptions,
|
|
197
|
-
openMemo = _ref.openMemo
|
|
198
|
+
openMemo = _ref.openMemo,
|
|
199
|
+
getDynamicFilterOptionsFn = _ref.getDynamicFilterOptionsFn;
|
|
198
200
|
var tableMaxRef = useRef(null);
|
|
199
201
|
// 表格元素
|
|
200
202
|
var tableContentRef = useRef(null);
|
|
@@ -376,17 +378,11 @@ var TableMax = function TableMax(_ref) {
|
|
|
376
378
|
setExpanded = _React$useState2[1];
|
|
377
379
|
|
|
378
380
|
// 固定列是否显示阴影
|
|
379
|
-
var
|
|
380
|
-
|
|
381
|
-
right: false
|
|
382
|
-
}),
|
|
381
|
+
var scrollRafId = useRef(null);
|
|
382
|
+
var _useState35 = useState(defaultCompactMode),
|
|
383
383
|
_useState36 = _slicedToArray(_useState35, 2),
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
var _useState37 = useState(defaultCompactMode),
|
|
387
|
-
_useState38 = _slicedToArray(_useState37, 2),
|
|
388
|
-
compactMode = _useState38[0],
|
|
389
|
-
setCompactMode = _useState38[1];
|
|
384
|
+
compactMode = _useState36[0],
|
|
385
|
+
setCompactMode = _useState36[1];
|
|
390
386
|
var onColumnVisibilityChange = function onColumnVisibilityChange(data) {
|
|
391
387
|
if (typeof data === 'function') {
|
|
392
388
|
var _Object$values, _Object$keys;
|
|
@@ -965,41 +961,16 @@ var TableMax = function TableMax(_ref) {
|
|
|
965
961
|
})) === null || _tableRows$find3 === void 0 ? void 0 : _tableRows$find3.original);
|
|
966
962
|
}
|
|
967
963
|
};
|
|
968
|
-
var getPinShadowInfo = useCallback(function () {
|
|
969
|
-
var _tableBodyRef$current = tableBodyRef === null || tableBodyRef === void 0 ? void 0 : tableBodyRef.current,
|
|
970
|
-
scrollWidth = _tableBodyRef$current.scrollWidth,
|
|
971
|
-
clientWidth = _tableBodyRef$current.clientWidth,
|
|
972
|
-
scrollLeft = _tableBodyRef$current.scrollLeft;
|
|
973
|
-
var newLeftShadowVisible, newRightShadowVisible;
|
|
974
|
-
newLeftShadowVisible = scrollLeft > 0;
|
|
975
|
-
newRightShadowVisible = scrollWidth - clientWidth - scrollLeft > 1; // 为什么大于1?排除掉小数的情况
|
|
976
|
-
if (pinShadowVisible.left !== newLeftShadowVisible || pinShadowVisible.right !== newRightShadowVisible) {
|
|
977
|
-
setPinShadowVisible({
|
|
978
|
-
left: newLeftShadowVisible,
|
|
979
|
-
right: newRightShadowVisible
|
|
980
|
-
});
|
|
981
|
-
}
|
|
982
|
-
}, [pinShadowVisible]);
|
|
983
|
-
useEffect(function () {
|
|
984
|
-
// 表格宽度变化时(比如调整页面宽度大小),重新计算是否展示阴影
|
|
985
|
-
getPinShadowInfo();
|
|
986
|
-
}, [tableContentRef === null || tableContentRef === void 0 || (_tableContentRef$curr = tableContentRef.current) === null || _tableContentRef$curr === void 0 ? void 0 : _tableContentRef$curr.clientWidth, table.getState().columnSizing]);
|
|
987
|
-
var scrollHandler = useCallback(function (event) {
|
|
988
|
-
if (!event.currentTarget) return;
|
|
989
|
-
tableHeaderRef.current.scrollLeft = event.currentTarget.scrollLeft / event.currentTarget.scrollWidth * (tableHeaderRef === null || tableHeaderRef === void 0 ? void 0 : tableHeaderRef.current.scrollWidth);
|
|
990
|
-
getPinShadowInfo();
|
|
991
|
-
}, [getPinShadowInfo]);
|
|
992
964
|
|
|
993
|
-
//
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
}, [columnVisibility, columnPinning, pinShadowVisible]);
|
|
965
|
+
// 横向滚动时,添加列固定阴影
|
|
966
|
+
useTableScrollShadow({
|
|
967
|
+
tableBodyRef: tableBodyRef,
|
|
968
|
+
tableHeaderRef: tableHeaderRef,
|
|
969
|
+
tableContentRef: tableContentRef,
|
|
970
|
+
table: table,
|
|
971
|
+
columnPinning: columnPinning,
|
|
972
|
+
columnSizing: columnSizing
|
|
973
|
+
});
|
|
1003
974
|
var tableHeaderProps = {
|
|
1004
975
|
tableId: tableId,
|
|
1005
976
|
tableContentRef: tableContentRef,
|
|
@@ -1012,10 +983,10 @@ var TableMax = function TableMax(_ref) {
|
|
|
1012
983
|
hasGroup: hasGroup,
|
|
1013
984
|
getHeaderCellProps: getHeaderCellProps,
|
|
1014
985
|
columnResizeMode: columnResizeMode,
|
|
1015
|
-
shadowColumnInfo: shadowColumnInfo,
|
|
1016
986
|
disableColumnDrag: disableColumnDrag,
|
|
1017
987
|
compactMode: compactMode,
|
|
1018
|
-
manualFiltering: manualFiltering
|
|
988
|
+
manualFiltering: manualFiltering,
|
|
989
|
+
getDynamicFilterOptionsFn: getDynamicFilterOptionsFn
|
|
1019
990
|
};
|
|
1020
991
|
var tableBodyProps = {
|
|
1021
992
|
tableContentRef: tableContentRef,
|
|
@@ -1061,7 +1032,6 @@ var TableMax = function TableMax(_ref) {
|
|
|
1061
1032
|
datas: datas,
|
|
1062
1033
|
theme: theme,
|
|
1063
1034
|
dragBeforeStart: dragBeforeStart,
|
|
1064
|
-
shadowColumnInfo: shadowColumnInfo,
|
|
1065
1035
|
getContextMenu: getContextMenu,
|
|
1066
1036
|
onClickContextMenu: onClickContextMenu,
|
|
1067
1037
|
getRowHoverTipConfig: getRowHoverTipConfig,
|
|
@@ -1148,39 +1118,68 @@ var TableMax = function TableMax(_ref) {
|
|
|
1148
1118
|
request: request
|
|
1149
1119
|
})));
|
|
1150
1120
|
}
|
|
1151
|
-
}), canRefresh && /*#__PURE__*/_jsx(
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1121
|
+
}), canRefresh && /*#__PURE__*/_jsx(Tooltip, {
|
|
1122
|
+
placement: "top",
|
|
1123
|
+
title: '刷新',
|
|
1124
|
+
children: /*#__PURE__*/_jsx("i", {
|
|
1125
|
+
className: "iconfont-table icon-table-shuaxin handleRightItem",
|
|
1126
|
+
style: {
|
|
1127
|
+
fontSize: '16px',
|
|
1128
|
+
marginRight: 0
|
|
1129
|
+
},
|
|
1130
|
+
onClick: function onClick() {
|
|
1131
|
+
return refreshFun === null || refreshFun === void 0 ? void 0 : refreshFun();
|
|
1132
|
+
}
|
|
1133
|
+
})
|
|
1160
1134
|
}), canEditting && /*#__PURE__*/_jsx("span", {
|
|
1161
1135
|
className: canClickEditIcon ? undefined : 'disableBtn',
|
|
1136
|
+
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
1137
|
+
placement: "top",
|
|
1138
|
+
title: '编辑',
|
|
1139
|
+
children: /*#__PURE__*/_jsx("i", {
|
|
1140
|
+
className: "iconfont-other icon-other-bianji handleRightItem",
|
|
1141
|
+
style: {
|
|
1142
|
+
fontSize: '16px',
|
|
1143
|
+
marginRight: 0
|
|
1144
|
+
},
|
|
1145
|
+
onClick: editFun
|
|
1146
|
+
})
|
|
1147
|
+
})
|
|
1148
|
+
}), canDelete && /*#__PURE__*/_jsx(Tooltip, {
|
|
1149
|
+
placement: "top",
|
|
1150
|
+
title: '删除',
|
|
1162
1151
|
children: /*#__PURE__*/_jsx("i", {
|
|
1163
|
-
className: "iconfont-
|
|
1152
|
+
className: "iconfont-table icon-table-delete handleRightItem",
|
|
1164
1153
|
style: {
|
|
1165
1154
|
fontSize: '16px',
|
|
1166
1155
|
marginRight: 0
|
|
1167
1156
|
},
|
|
1168
|
-
onClick:
|
|
1157
|
+
onClick: handleClickDelete
|
|
1158
|
+
})
|
|
1159
|
+
}), canFilter && /*#__PURE__*/_jsx(Tooltip, {
|
|
1160
|
+
placement: "top",
|
|
1161
|
+
title: '重置筛选',
|
|
1162
|
+
children: /*#__PURE__*/_jsx("i", {
|
|
1163
|
+
className: "iconfont-table icon-table-refresh handleRightItem",
|
|
1164
|
+
style: {
|
|
1165
|
+
fontSize: '16px',
|
|
1166
|
+
marginRight: 0
|
|
1167
|
+
},
|
|
1168
|
+
onClick: function onClick() {
|
|
1169
|
+
setColumnFilters(defaultColumnFilters);
|
|
1170
|
+
}
|
|
1171
|
+
})
|
|
1172
|
+
}), canCompact && /*#__PURE__*/_jsx(Tooltip, {
|
|
1173
|
+
placement: "top",
|
|
1174
|
+
title: compactMode ? '标准模式' : '紧凑模式',
|
|
1175
|
+
children: /*#__PURE__*/_jsx("i", {
|
|
1176
|
+
className: "iconfont-table ".concat(compactMode ? 'icon-table-normal' : 'icon-table-tight', " handleRightItem"),
|
|
1177
|
+
style: {
|
|
1178
|
+
fontSize: '16px',
|
|
1179
|
+
marginRight: 0
|
|
1180
|
+
},
|
|
1181
|
+
onClick: changeCompactMode
|
|
1169
1182
|
})
|
|
1170
|
-
}), canDelete && /*#__PURE__*/_jsx("i", {
|
|
1171
|
-
className: "iconfont-table icon-table-delete handleRightItem",
|
|
1172
|
-
style: {
|
|
1173
|
-
fontSize: '16px',
|
|
1174
|
-
marginRight: 0
|
|
1175
|
-
},
|
|
1176
|
-
onClick: handleClickDelete
|
|
1177
|
-
}), canCompact && /*#__PURE__*/_jsx("i", {
|
|
1178
|
-
className: "iconfont-table ".concat(compactMode ? 'icon-table-normal' : 'icon-table-tight', " handleRightItem"),
|
|
1179
|
-
style: {
|
|
1180
|
-
fontSize: '16px',
|
|
1181
|
-
marginRight: 0
|
|
1182
|
-
},
|
|
1183
|
-
onClick: changeCompactMode
|
|
1184
1183
|
}), canSetting && /*#__PURE__*/_jsx(ColumnSetting, {
|
|
1185
1184
|
table: table,
|
|
1186
1185
|
tableId: tableId,
|
|
@@ -1221,20 +1220,21 @@ var TableMax = function TableMax(_ref) {
|
|
|
1221
1220
|
})]
|
|
1222
1221
|
}), /*#__PURE__*/_jsx("div", {
|
|
1223
1222
|
ref: tableBodyRef,
|
|
1224
|
-
className: "table-body"
|
|
1225
|
-
onScroll
|
|
1223
|
+
className: "table-body"
|
|
1224
|
+
// onScroll={scrollHandler}
|
|
1225
|
+
,
|
|
1226
1226
|
style: {
|
|
1227
1227
|
width: "100%"
|
|
1228
1228
|
},
|
|
1229
1229
|
onMouseEnter: function onMouseEnter() {
|
|
1230
|
-
var _tableBodyRef$
|
|
1230
|
+
var _tableBodyRef$current;
|
|
1231
1231
|
// 给当前元素添加hover类
|
|
1232
|
-
(_tableBodyRef$
|
|
1232
|
+
(_tableBodyRef$current = tableBodyRef.current) === null || _tableBodyRef$current === void 0 || _tableBodyRef$current.classList.add('hover-active');
|
|
1233
1233
|
},
|
|
1234
1234
|
onMouseLeave: function onMouseLeave() {
|
|
1235
|
-
var _tableBodyRef$
|
|
1235
|
+
var _tableBodyRef$current2;
|
|
1236
1236
|
// 移除当前元素的hover类
|
|
1237
|
-
(_tableBodyRef$
|
|
1237
|
+
(_tableBodyRef$current2 = tableBodyRef.current) === null || _tableBodyRef$current2 === void 0 || _tableBodyRef$current2.classList.remove('hover-active');
|
|
1238
1238
|
},
|
|
1239
1239
|
children: /*#__PURE__*/_jsx(TableBody, _objectSpread({}, tableBodyProps))
|
|
1240
1240
|
})]
|
|
@@ -13,20 +13,27 @@ import { AutoComplete, DatePicker, Input, InputNumber } from 'antd';
|
|
|
13
13
|
import dayjs from 'dayjs';
|
|
14
14
|
import { debounce } from 'lodash';
|
|
15
15
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
16
|
-
import { FilterType, defaultDateFormat, isEmpty } from '.';
|
|
16
|
+
import { FilterType, defaultDateFormat, isEmpty, uniqueByField } from '.';
|
|
17
|
+
import { FilterOperator } from "../../type";
|
|
17
18
|
import { DateRange } from "./DateRange";
|
|
18
19
|
import MultipleSelect from "./MultipleSelect";
|
|
19
20
|
import NumberRange from "./NumberRange";
|
|
20
21
|
import SingleSelect from "./SingleSelect";
|
|
21
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
23
|
var Filter = function Filter(_ref) {
|
|
23
|
-
var
|
|
24
|
+
var getDynamicFilterOptionsFn = _ref.getDynamicFilterOptionsFn,
|
|
25
|
+
column = _ref.column,
|
|
24
26
|
onCloseFilterPanel = _ref.onCloseFilterPanel,
|
|
25
27
|
manualFiltering = _ref.manualFiltering;
|
|
26
28
|
var columnDef = column === null || column === void 0 ? void 0 : column.columnDef;
|
|
27
29
|
// 筛选组件类型
|
|
28
|
-
var
|
|
30
|
+
var id = columnDef.id,
|
|
31
|
+
accessorKey = columnDef.accessorKey,
|
|
32
|
+
filterType = columnDef.filterType,
|
|
29
33
|
filterOptions = columnDef.filterOptions,
|
|
34
|
+
dynamicFilterOptionsLabelFn = columnDef.dynamicFilterOptionsLabelFn,
|
|
35
|
+
dynamicFilterOptionsLabelField = columnDef.dynamicFilterOptionsLabelField,
|
|
36
|
+
dynamicFilterOptionsValueField = columnDef.dynamicFilterOptionsValueField,
|
|
30
37
|
getFilterOptionsFn = columnDef.getFilterOptionsFn,
|
|
31
38
|
_columnDef$isFilterOp = columnDef.isFilterOptionsFrontSearch,
|
|
32
39
|
isFilterOptionsFrontSearch = _columnDef$isFilterOp === void 0 ? false : _columnDef$isFilterOp;
|
|
@@ -46,6 +53,16 @@ var Filter = function Filter(_ref) {
|
|
|
46
53
|
apiLoading = _useState6[0],
|
|
47
54
|
setApiLoading = _useState6[1];
|
|
48
55
|
|
|
56
|
+
// 动态接口可选值
|
|
57
|
+
var _useState7 = useState([]),
|
|
58
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
59
|
+
dynamicApiOptions = _useState8[0],
|
|
60
|
+
setDynamicApiOptions = _useState8[1];
|
|
61
|
+
var _useState9 = useState(false),
|
|
62
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
63
|
+
dynamicApiLoading = _useState10[0],
|
|
64
|
+
setDynamicApiLoading = _useState10[1];
|
|
65
|
+
|
|
49
66
|
// 修改表格筛选参数
|
|
50
67
|
var handleChangeFilterValue = function handleChangeFilterValue(value) {
|
|
51
68
|
var newValue = value;
|
|
@@ -91,6 +108,9 @@ var Filter = function Filter(_ref) {
|
|
|
91
108
|
changeFilterValueWithDebounce(value);
|
|
92
109
|
setColumnFilterValue(value);
|
|
93
110
|
};
|
|
111
|
+
var loading = useMemo(function () {
|
|
112
|
+
return apiLoading || dynamicApiLoading;
|
|
113
|
+
}, [apiLoading, dynamicApiLoading]);
|
|
94
114
|
|
|
95
115
|
// 最终展示的可选值
|
|
96
116
|
var options = useMemo(function () {
|
|
@@ -102,10 +122,14 @@ var Filter = function Filter(_ref) {
|
|
|
102
122
|
if (filterOptions) {
|
|
103
123
|
return filterOptions;
|
|
104
124
|
}
|
|
105
|
-
//
|
|
125
|
+
// 列配置接口获取的可选值
|
|
106
126
|
if (getFilterOptionsFn && Array.isArray(apiOptions)) {
|
|
107
127
|
return apiOptions;
|
|
108
128
|
}
|
|
129
|
+
// 动态接口获取的可选值
|
|
130
|
+
if (getDynamicFilterOptionsFn && Array.isArray(dynamicApiOptions)) {
|
|
131
|
+
return dynamicApiOptions;
|
|
132
|
+
}
|
|
109
133
|
// 后端筛选时,不再填充可选值
|
|
110
134
|
if (manualFiltering) {
|
|
111
135
|
return [];
|
|
@@ -119,17 +143,17 @@ var Filter = function Filter(_ref) {
|
|
|
119
143
|
label: item + ''
|
|
120
144
|
};
|
|
121
145
|
});
|
|
122
|
-
}, [column.getFacetedUniqueValues(), filterOptions, manualFiltering, apiOptions]);
|
|
146
|
+
}, [column.getFacetedUniqueValues(), filterOptions, manualFiltering, apiOptions, dynamicApiOptions]);
|
|
123
147
|
|
|
124
148
|
// 调用接口获取可选值
|
|
125
149
|
var fetchOptions = useCallback( /*#__PURE__*/function () {
|
|
126
150
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(inputValue) {
|
|
127
|
-
var res;
|
|
151
|
+
var res, _ref3, _ref4, filterField, valueField, filter, _res, uniqueData, _options;
|
|
128
152
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
129
153
|
while (1) switch (_context.prev = _context.next) {
|
|
130
154
|
case 0:
|
|
131
155
|
if (!getFilterOptionsFn) {
|
|
132
|
-
_context.next =
|
|
156
|
+
_context.next = 15;
|
|
133
157
|
break;
|
|
134
158
|
}
|
|
135
159
|
_context.prev = 1;
|
|
@@ -148,16 +172,55 @@ var Filter = function Filter(_ref) {
|
|
|
148
172
|
setApiOptions([]);
|
|
149
173
|
case 12:
|
|
150
174
|
setApiLoading(false);
|
|
151
|
-
|
|
175
|
+
_context.next = 33;
|
|
176
|
+
break;
|
|
177
|
+
case 15:
|
|
178
|
+
if (!getDynamicFilterOptionsFn) {
|
|
179
|
+
_context.next = 33;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
setDynamicApiLoading(true);
|
|
183
|
+
_context.prev = 17;
|
|
184
|
+
filterField = (_ref3 = dynamicFilterOptionsLabelField !== null && dynamicFilterOptionsLabelField !== void 0 ? dynamicFilterOptionsLabelField : id) !== null && _ref3 !== void 0 ? _ref3 : accessorKey;
|
|
185
|
+
valueField = (_ref4 = dynamicFilterOptionsValueField !== null && dynamicFilterOptionsValueField !== void 0 ? dynamicFilterOptionsValueField : id) !== null && _ref4 !== void 0 ? _ref4 : accessorKey;
|
|
186
|
+
filter = inputValue ? {
|
|
187
|
+
field: filterField,
|
|
188
|
+
operator: FilterOperator.Contains,
|
|
189
|
+
value: inputValue
|
|
190
|
+
} : undefined;
|
|
191
|
+
_context.next = 23;
|
|
192
|
+
return getDynamicFilterOptionsFn(filter, filterField, inputValue);
|
|
193
|
+
case 23:
|
|
194
|
+
_res = _context.sent;
|
|
195
|
+
uniqueData = uniqueByField(_res, [valueField]);
|
|
196
|
+
_options = uniqueData.map(function (item) {
|
|
197
|
+
var _ref5, _ref6, _dynamicFilterOptions;
|
|
198
|
+
var label = (_ref5 = (_ref6 = (_dynamicFilterOptions = dynamicFilterOptionsLabelFn === null || dynamicFilterOptionsLabelFn === void 0 ? void 0 : dynamicFilterOptionsLabelFn(item)) !== null && _dynamicFilterOptions !== void 0 ? _dynamicFilterOptions : item === null || item === void 0 ? void 0 : item[dynamicFilterOptionsLabelField]) !== null && _ref6 !== void 0 ? _ref6 : item === null || item === void 0 ? void 0 : item[id]) !== null && _ref5 !== void 0 ? _ref5 : item === null || item === void 0 ? void 0 : item[accessorKey];
|
|
199
|
+
var value = item === null || item === void 0 ? void 0 : item[valueField];
|
|
200
|
+
return {
|
|
201
|
+
label: label,
|
|
202
|
+
value: value
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
setDynamicApiOptions(_options);
|
|
206
|
+
_context.next = 32;
|
|
207
|
+
break;
|
|
208
|
+
case 29:
|
|
209
|
+
_context.prev = 29;
|
|
210
|
+
_context.t1 = _context["catch"](17);
|
|
211
|
+
setDynamicApiOptions([]);
|
|
212
|
+
case 32:
|
|
213
|
+
setDynamicApiLoading(false);
|
|
214
|
+
case 33:
|
|
152
215
|
case "end":
|
|
153
216
|
return _context.stop();
|
|
154
217
|
}
|
|
155
|
-
}, _callee, null, [[1, 9]]);
|
|
218
|
+
}, _callee, null, [[1, 9], [17, 29]]);
|
|
156
219
|
}));
|
|
157
220
|
return function (_x) {
|
|
158
221
|
return _ref2.apply(this, arguments);
|
|
159
222
|
};
|
|
160
|
-
}(), [getFilterOptionsFn]);
|
|
223
|
+
}(), [getFilterOptionsFn, getDynamicFilterOptionsFn]);
|
|
161
224
|
var onSearch = useCallback(debounce(function (value) {
|
|
162
225
|
// console.log('onSearch', value);
|
|
163
226
|
fetchOptions(value);
|
|
@@ -165,8 +228,8 @@ var Filter = function Filter(_ref) {
|
|
|
165
228
|
useEffect(function () {
|
|
166
229
|
if ([FilterType.SingleSelect, FilterType.MultiSelect].includes(filterType)) {
|
|
167
230
|
// 打开后自动获取可选值
|
|
168
|
-
var
|
|
169
|
-
optionsParam =
|
|
231
|
+
var _ref7 = columnFilterValue || {},
|
|
232
|
+
optionsParam = _ref7.optionsParam;
|
|
170
233
|
fetchOptions(optionsParam);
|
|
171
234
|
}
|
|
172
235
|
}, []);
|
|
@@ -276,7 +339,7 @@ var Filter = function Filter(_ref) {
|
|
|
276
339
|
options: options,
|
|
277
340
|
isFrontSearch: isFilterOptionsFrontSearch,
|
|
278
341
|
onCloseFilterPanel: onCloseFilterPanel,
|
|
279
|
-
loading:
|
|
342
|
+
loading: loading
|
|
280
343
|
});
|
|
281
344
|
case FilterType.MultiSelect:
|
|
282
345
|
default:
|
|
@@ -285,7 +348,7 @@ var Filter = function Filter(_ref) {
|
|
|
285
348
|
onChange: handleChangeSelectFilterValue,
|
|
286
349
|
onSearch: onSearch,
|
|
287
350
|
options: options,
|
|
288
|
-
loading:
|
|
351
|
+
loading: loading,
|
|
289
352
|
isFrontSearch: isFilterOptionsFrontSearch,
|
|
290
353
|
onCloseFilterPanel: onCloseFilterPanel
|
|
291
354
|
});
|
|
@@ -30,8 +30,10 @@ export type IFilterFnEnum = {
|
|
|
30
30
|
[key in FilterType]: FilterFnType;
|
|
31
31
|
};
|
|
32
32
|
export declare function setDefaultFilterFn(columns: TableMaxColumnType[]): TableMaxColumnType[];
|
|
33
|
-
export declare function ColumnFilter({ column, manualFiltering }: {
|
|
33
|
+
export declare function ColumnFilter({ column, manualFiltering, getDynamicFilterOptionsFn }: {
|
|
34
34
|
column: Column<any, unknown>;
|
|
35
35
|
manualFiltering: boolean;
|
|
36
|
+
getDynamicFilterOptionsFn: Function;
|
|
36
37
|
}): import("react/jsx-runtime").JSX.Element;
|
|
37
38
|
export declare function isEmpty(value: any): boolean;
|
|
39
|
+
export declare function uniqueByField(arr: any, field: any): any;
|
|
@@ -64,7 +64,8 @@ export function setDefaultFilterFn(columns) {
|
|
|
64
64
|
}
|
|
65
65
|
export function ColumnFilter(_ref) {
|
|
66
66
|
var column = _ref.column,
|
|
67
|
-
manualFiltering = _ref.manualFiltering
|
|
67
|
+
manualFiltering = _ref.manualFiltering,
|
|
68
|
+
getDynamicFilterOptionsFn = _ref.getDynamicFilterOptionsFn;
|
|
68
69
|
var _useConfig = useConfig(),
|
|
69
70
|
root = _useConfig.root;
|
|
70
71
|
var _useState = useState(false),
|
|
@@ -84,10 +85,10 @@ export function ColumnFilter(_ref) {
|
|
|
84
85
|
setFilterPanelVisible(false);
|
|
85
86
|
};
|
|
86
87
|
if (filterPanelVisible) {
|
|
87
|
-
window.addEventListener('
|
|
88
|
+
window.addEventListener('mousedown', clickHandler);
|
|
88
89
|
}
|
|
89
90
|
return function () {
|
|
90
|
-
window.removeEventListener('
|
|
91
|
+
window.removeEventListener('mousedown', clickHandler);
|
|
91
92
|
};
|
|
92
93
|
}, [filterPanelVisible]);
|
|
93
94
|
|
|
@@ -148,7 +149,11 @@ export function ColumnFilter(_ref) {
|
|
|
148
149
|
onClick: function onClick(e) {
|
|
149
150
|
return e.stopPropagation();
|
|
150
151
|
},
|
|
152
|
+
onMouseDown: function onMouseDown(e) {
|
|
153
|
+
return e.stopPropagation();
|
|
154
|
+
},
|
|
151
155
|
children: /*#__PURE__*/_jsx(Filter, {
|
|
156
|
+
getDynamicFilterOptionsFn: getDynamicFilterOptionsFn,
|
|
152
157
|
column: column,
|
|
153
158
|
onCloseFilterPanel: handleClosePanel,
|
|
154
159
|
manualFiltering: manualFiltering
|
|
@@ -160,4 +165,15 @@ export function isEmpty(value) {
|
|
|
160
165
|
if (value) return false;
|
|
161
166
|
if (value === false || value === 0) return false;
|
|
162
167
|
return true;
|
|
168
|
+
}
|
|
169
|
+
export function uniqueByField(arr, field) {
|
|
170
|
+
var map = new Map();
|
|
171
|
+
return arr.filter(function (item) {
|
|
172
|
+
var key = item[field];
|
|
173
|
+
if (!map.has(key)) {
|
|
174
|
+
map.set(key, true);
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
});
|
|
163
179
|
}
|
|
@@ -343,9 +343,13 @@ var ColumnSetting = function ColumnSetting(_ref3) {
|
|
|
343
343
|
onClick: function onClick(e) {
|
|
344
344
|
return e.stopPropagation();
|
|
345
345
|
},
|
|
346
|
-
children: [/*#__PURE__*/_jsx(
|
|
347
|
-
|
|
348
|
-
|
|
346
|
+
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
347
|
+
placement: "top",
|
|
348
|
+
title: '设置',
|
|
349
|
+
children: /*#__PURE__*/_jsx("i", {
|
|
350
|
+
className: "handleRightItem icon iconfont-table icon-table-shezhi",
|
|
351
|
+
onClick: onColumnConfigClick
|
|
352
|
+
})
|
|
349
353
|
}), settingVisible ? /*#__PURE__*/createPortal( /*#__PURE__*/_jsxs("div", {
|
|
350
354
|
ref: configWrapperRef,
|
|
351
355
|
className: "column-config-wapper",
|
|
@@ -125,10 +125,12 @@ export var useColumnResize = function useColumnResize(_ref) {
|
|
|
125
125
|
|
|
126
126
|
// 立即更新列宽(关键修改点)
|
|
127
127
|
var finalDelta = lastClientXRef.current - startXRef.current;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
if (finalDelta) {
|
|
129
|
+
var newWidth = Math.max(20, startWidthRef.current + finalDelta);
|
|
130
|
+
table.setColumnSizing(function (old) {
|
|
131
|
+
return _objectSpread(_objectSpread({}, old), {}, _defineProperty({}, header.column.id, newWidth));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
132
134
|
|
|
133
135
|
// 隐藏元素
|
|
134
136
|
if (resizeLineRef.current) {
|
|
@@ -244,9 +244,10 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
244
244
|
*/
|
|
245
245
|
var handleColumnSizingChange = useCallback(function (updater) {
|
|
246
246
|
var changedColumn = updater();
|
|
247
|
-
if (!changedColumn) return;
|
|
247
|
+
if (!changedColumn || JSON.stringify(changedColumn) === '{}') return;
|
|
248
248
|
setState(produce(function (prevState) {
|
|
249
|
-
var
|
|
249
|
+
var _Object$entries;
|
|
250
|
+
var _ref2 = (_Object$entries = Object.entries(changedColumn)) === null || _Object$entries === void 0 ? void 0 : _Object$entries[0],
|
|
250
251
|
_ref3 = _slicedToArray(_ref2, 2),
|
|
251
252
|
changedKey = _ref3[0],
|
|
252
253
|
newWidth = _ref3[1];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { SWRInfiniteConfiguration } from 'swr/infinite';
|
|
3
|
+
interface UseInfiniteScrollOptions<T> {
|
|
4
|
+
getKey: (pageIndex: number, previousPageData: T | null) => any;
|
|
5
|
+
fetcher: (params: any) => Promise<T>;
|
|
6
|
+
pageSize?: number;
|
|
7
|
+
swrOptions?: SWRInfiniteConfiguration;
|
|
8
|
+
rootMargin?: string;
|
|
9
|
+
threshold?: number;
|
|
10
|
+
}
|
|
11
|
+
interface UseInfiniteScrollReturn<T> {
|
|
12
|
+
data: T[] | undefined;
|
|
13
|
+
items: any[];
|
|
14
|
+
size: number;
|
|
15
|
+
setSize: (size: number | ((_size: number) => number)) => Promise<any[]>;
|
|
16
|
+
isValidating: boolean;
|
|
17
|
+
isLoadingMore: boolean;
|
|
18
|
+
hasMore: boolean;
|
|
19
|
+
error: any;
|
|
20
|
+
loadMore: () => void;
|
|
21
|
+
triggerRef: React.RefObject<HTMLDivElement>;
|
|
22
|
+
}
|
|
23
|
+
export declare function useInfiniteScroll<T extends {
|
|
24
|
+
items?: any[];
|
|
25
|
+
totalCount?: number;
|
|
26
|
+
hasMore?: boolean;
|
|
27
|
+
}>({ getKey, fetcher, pageSize, swrOptions, rootMargin, threshold }: UseInfiniteScrollOptions<T>): UseInfiniteScrollReturn<T>;
|
|
28
|
+
export {};
|