@arim-aisdc/public-components 2.3.39 → 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/BaseInfo/BaseInfo.d.ts +1 -1
- 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 -1
- package/dist/components/TableMax/TableHeader/index.js +4 -2
- package/dist/components/TableMax/TableMax.js +59 -28
- 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/components/ColumnSort/customSortFns.d.ts +8 -8
- package/dist/components/TableMax/hooks/useInfiniteScroll.d.ts +28 -0
- package/dist/components/TableMax/hooks/useInfiniteScroll.js +95 -0
- package/dist/components/TableMax/type.d.ts +12 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@font-face {
|
|
2
2
|
font-family: "iconfont-table"; /* Project id 4453758 */
|
|
3
|
-
src: url('iconfont.ttf?t=
|
|
3
|
+
src: url('./iconfont.ttf?t=1760947738405') format('truetype');
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
.iconfont-table {
|
|
@@ -11,6 +11,14 @@
|
|
|
11
11
|
-moz-osx-font-smoothing: grayscale;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
.icon-table-refresh:before {
|
|
15
|
+
content: "\e8d9";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.icon-table-gengduo:before {
|
|
19
|
+
content: "\e665";
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
.icon-table-sort:before {
|
|
15
23
|
content: "\e890";
|
|
16
24
|
}
|
|
Binary file
|
|
@@ -17,7 +17,7 @@ export declare const foramtBaseInfoField: (data: any, dataField: BaseInfoFieldTy
|
|
|
17
17
|
value: any;
|
|
18
18
|
field: string;
|
|
19
19
|
label?: string;
|
|
20
|
-
text: string | Element |
|
|
20
|
+
text: string | JSX.Element | Element;
|
|
21
21
|
units?: string;
|
|
22
22
|
width?: string;
|
|
23
23
|
labelWidth?: string;
|
|
@@ -14,6 +14,7 @@ type ICellType = {
|
|
|
14
14
|
headerRowNum: number;
|
|
15
15
|
canFilter?: boolean;
|
|
16
16
|
manualFiltering: boolean;
|
|
17
|
+
getDynamicFilterOptionsFn?: Function;
|
|
17
18
|
};
|
|
18
|
-
declare const Cell: ({ tableContentRef, header, table, hasGroup, canSorting, getHeaderCellProps, disableColumnDrag, headerRowNum, canFilter, manualFiltering, }: ICellType) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
declare const Cell: ({ tableContentRef, header, table, hasGroup, canSorting, getHeaderCellProps, disableColumnDrag, headerRowNum, canFilter, manualFiltering, getDynamicFilterOptionsFn }: ICellType) => import("react/jsx-runtime").JSX.Element;
|
|
19
20
|
export default Cell;
|
|
@@ -41,7 +41,8 @@ var Cell = function Cell(_ref) {
|
|
|
41
41
|
disableColumnDrag = _ref.disableColumnDrag,
|
|
42
42
|
headerRowNum = _ref.headerRowNum,
|
|
43
43
|
canFilter = _ref.canFilter,
|
|
44
|
-
manualFiltering = _ref.manualFiltering
|
|
44
|
+
manualFiltering = _ref.manualFiltering,
|
|
45
|
+
getDynamicFilterOptionsFn = _ref.getDynamicFilterOptionsFn;
|
|
45
46
|
var _useConfig = useConfig(),
|
|
46
47
|
root = _useConfig.root;
|
|
47
48
|
var cannotDragColumn = [ColumnType.Darg, ColumnType.Selection, ColumnType.Expander, ColumnType.PlaceHolder];
|
|
@@ -131,7 +132,8 @@ var Cell = function Cell(_ref) {
|
|
|
131
132
|
onClick: header.column.getToggleSortingHandler()
|
|
132
133
|
}) : null, canFilter && columnDef.enableColumnFilter !== false ? /*#__PURE__*/_jsx(ColumnFilter, {
|
|
133
134
|
column: header.column,
|
|
134
|
-
manualFiltering: manualFiltering
|
|
135
|
+
manualFiltering: manualFiltering,
|
|
136
|
+
getDynamicFilterOptionsFn: getDynamicFilterOptionsFn
|
|
135
137
|
}) : null]
|
|
136
138
|
}) : null, /*#__PURE__*/_jsx("div", {
|
|
137
139
|
className: "cell-resize-handler ".concat(header.column.getIsResizing() ? 'column-is-resizing' : ''),
|
|
@@ -15,6 +15,7 @@ type TableHeaderProps = {
|
|
|
15
15
|
disableColumnDrag?: boolean;
|
|
16
16
|
headerRowNum: number;
|
|
17
17
|
manualFiltering: boolean;
|
|
18
|
+
getDynamicFilterOptionsFn?: Function;
|
|
18
19
|
};
|
|
19
|
-
declare const TableHeader: ({ tableContentRef, table, canFilter, enableFilters, canSorting, hasGroup, getHeaderCellProps, columnResizeMode, disableColumnDrag, rowHeight, headerRowNum, manualFiltering, }: TableHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare const TableHeader: ({ tableContentRef, table, canFilter, enableFilters, canSorting, hasGroup, getHeaderCellProps, columnResizeMode, disableColumnDrag, rowHeight, headerRowNum, manualFiltering, getDynamicFilterOptionsFn }: TableHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
21
|
export default TableHeader;
|
|
@@ -28,7 +28,8 @@ var TableHeader = function TableHeader(_ref) {
|
|
|
28
28
|
disableColumnDrag = _ref.disableColumnDrag,
|
|
29
29
|
rowHeight = _ref.rowHeight,
|
|
30
30
|
headerRowNum = _ref.headerRowNum,
|
|
31
|
-
manualFiltering = _ref.manualFiltering
|
|
31
|
+
manualFiltering = _ref.manualFiltering,
|
|
32
|
+
getDynamicFilterOptionsFn = _ref.getDynamicFilterOptionsFn;
|
|
32
33
|
var headerGroups = table.getHeaderGroups();
|
|
33
34
|
var headers = (headerGroups === null || headerGroups === void 0 || (_headerGroups = headerGroups[headerGroups.length - 1]) === null || _headerGroups === void 0 ? void 0 : _headerGroups.headers) || [];
|
|
34
35
|
useWhyDidYouUpdate('useWhyDidYouUpdate', {
|
|
@@ -77,7 +78,8 @@ var TableHeader = function TableHeader(_ref) {
|
|
|
77
78
|
disableColumnDrag: disableColumnDrag,
|
|
78
79
|
headerRowNum: headerRowNum,
|
|
79
80
|
canFilter: canFilter,
|
|
80
|
-
manualFiltering: manualFiltering
|
|
81
|
+
manualFiltering: manualFiltering,
|
|
82
|
+
getDynamicFilterOptionsFn: getDynamicFilterOptionsFn
|
|
81
83
|
}, header.id)
|
|
82
84
|
}, header.id);
|
|
83
85
|
})
|
|
@@ -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';
|
|
@@ -195,7 +195,8 @@ var TableMax = function TableMax(_ref) {
|
|
|
195
195
|
hasTotalRow = _ref.hasTotalRow,
|
|
196
196
|
totalDatas = _ref.totalDatas,
|
|
197
197
|
pageSizeOptions = _ref.pageSizeOptions,
|
|
198
|
-
openMemo = _ref.openMemo
|
|
198
|
+
openMemo = _ref.openMemo,
|
|
199
|
+
getDynamicFilterOptionsFn = _ref.getDynamicFilterOptionsFn;
|
|
199
200
|
var tableMaxRef = useRef(null);
|
|
200
201
|
// 表格元素
|
|
201
202
|
var tableContentRef = useRef(null);
|
|
@@ -984,7 +985,8 @@ var TableMax = function TableMax(_ref) {
|
|
|
984
985
|
columnResizeMode: columnResizeMode,
|
|
985
986
|
disableColumnDrag: disableColumnDrag,
|
|
986
987
|
compactMode: compactMode,
|
|
987
|
-
manualFiltering: manualFiltering
|
|
988
|
+
manualFiltering: manualFiltering,
|
|
989
|
+
getDynamicFilterOptionsFn: getDynamicFilterOptionsFn
|
|
988
990
|
};
|
|
989
991
|
var tableBodyProps = {
|
|
990
992
|
tableContentRef: tableContentRef,
|
|
@@ -1116,39 +1118,68 @@ var TableMax = function TableMax(_ref) {
|
|
|
1116
1118
|
request: request
|
|
1117
1119
|
})));
|
|
1118
1120
|
}
|
|
1119
|
-
}), canRefresh && /*#__PURE__*/_jsx(
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
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
|
+
})
|
|
1128
1134
|
}), canEditting && /*#__PURE__*/_jsx("span", {
|
|
1129
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: '删除',
|
|
1130
1151
|
children: /*#__PURE__*/_jsx("i", {
|
|
1131
|
-
className: "iconfont-
|
|
1152
|
+
className: "iconfont-table icon-table-delete handleRightItem",
|
|
1132
1153
|
style: {
|
|
1133
1154
|
fontSize: '16px',
|
|
1134
1155
|
marginRight: 0
|
|
1135
1156
|
},
|
|
1136
|
-
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
|
|
1137
1182
|
})
|
|
1138
|
-
}), canDelete && /*#__PURE__*/_jsx("i", {
|
|
1139
|
-
className: "iconfont-table icon-table-delete handleRightItem",
|
|
1140
|
-
style: {
|
|
1141
|
-
fontSize: '16px',
|
|
1142
|
-
marginRight: 0
|
|
1143
|
-
},
|
|
1144
|
-
onClick: handleClickDelete
|
|
1145
|
-
}), canCompact && /*#__PURE__*/_jsx("i", {
|
|
1146
|
-
className: "iconfont-table ".concat(compactMode ? 'icon-table-normal' : 'icon-table-tight', " handleRightItem"),
|
|
1147
|
-
style: {
|
|
1148
|
-
fontSize: '16px',
|
|
1149
|
-
marginRight: 0
|
|
1150
|
-
},
|
|
1151
|
-
onClick: changeCompactMode
|
|
1152
1183
|
}), canSetting && /*#__PURE__*/_jsx(ColumnSetting, {
|
|
1153
1184
|
table: table,
|
|
1154
1185
|
tableId: tableId,
|
|
@@ -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",
|
|
@@ -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,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 {};
|
|
@@ -0,0 +1,95 @@
|
|
|
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/useInfiniteScroll.ts
|
|
8
|
+
import { useEffect, useRef, useCallback, useMemo } from 'react';
|
|
9
|
+
import useSWRInfinite from 'swr/infinite';
|
|
10
|
+
export function useInfiniteScroll(_ref) {
|
|
11
|
+
var getKey = _ref.getKey,
|
|
12
|
+
fetcher = _ref.fetcher,
|
|
13
|
+
_ref$pageSize = _ref.pageSize,
|
|
14
|
+
pageSize = _ref$pageSize === void 0 ? 20 : _ref$pageSize,
|
|
15
|
+
_ref$swrOptions = _ref.swrOptions,
|
|
16
|
+
swrOptions = _ref$swrOptions === void 0 ? {} : _ref$swrOptions,
|
|
17
|
+
_ref$rootMargin = _ref.rootMargin,
|
|
18
|
+
rootMargin = _ref$rootMargin === void 0 ? '100px' : _ref$rootMargin,
|
|
19
|
+
_ref$threshold = _ref.threshold,
|
|
20
|
+
threshold = _ref$threshold === void 0 ? 0.1 : _ref$threshold;
|
|
21
|
+
var _useSWRInfinite = useSWRInfinite(getKey, fetcher, _objectSpread({
|
|
22
|
+
revalidateFirstPage: false,
|
|
23
|
+
revalidateOnFocus: false
|
|
24
|
+
}, swrOptions)),
|
|
25
|
+
data = _useSWRInfinite.data,
|
|
26
|
+
size = _useSWRInfinite.size,
|
|
27
|
+
setSize = _useSWRInfinite.setSize,
|
|
28
|
+
isValidating = _useSWRInfinite.isValidating,
|
|
29
|
+
error = _useSWRInfinite.error;
|
|
30
|
+
|
|
31
|
+
// 计算状态
|
|
32
|
+
var items = useMemo(function () {
|
|
33
|
+
return (data === null || data === void 0 ? void 0 : data.flatMap(function (page) {
|
|
34
|
+
return (page === null || page === void 0 ? void 0 : page.items) || [];
|
|
35
|
+
})) || [];
|
|
36
|
+
}, [data]);
|
|
37
|
+
var lastPage = data === null || data === void 0 ? void 0 : data[data.length - 1];
|
|
38
|
+
var hasMore = useMemo(function () {
|
|
39
|
+
if ((lastPage === null || lastPage === void 0 ? void 0 : lastPage.hasMore) === false) return false;
|
|
40
|
+
if ((lastPage === null || lastPage === void 0 ? void 0 : lastPage.totalCount) !== undefined) {
|
|
41
|
+
return items.length < lastPage.totalCount;
|
|
42
|
+
}
|
|
43
|
+
// 如果没有 totalCount,根据 items 长度判断
|
|
44
|
+
return !lastPage || lastPage.items && lastPage.items.length >= pageSize;
|
|
45
|
+
}, [lastPage, items.length, pageSize]);
|
|
46
|
+
var isLoadingMore = isValidating && size > 0;
|
|
47
|
+
|
|
48
|
+
// 滚动触发相关逻辑
|
|
49
|
+
var observerRef = useRef();
|
|
50
|
+
var triggerRef = useRef(null);
|
|
51
|
+
|
|
52
|
+
// 加载更多回调
|
|
53
|
+
var loadMore = useCallback(function () {
|
|
54
|
+
if (hasMore && !isLoadingMore) {
|
|
55
|
+
setSize(size + 1);
|
|
56
|
+
}
|
|
57
|
+
}, [hasMore, isLoadingMore, setSize, size]);
|
|
58
|
+
|
|
59
|
+
// 观察器回调
|
|
60
|
+
var handleObserver = useCallback(function (entries) {
|
|
61
|
+
var target = entries[0];
|
|
62
|
+
if (target.isIntersecting) {
|
|
63
|
+
loadMore();
|
|
64
|
+
}
|
|
65
|
+
}, [loadMore]);
|
|
66
|
+
|
|
67
|
+
// 设置 Intersection Observer
|
|
68
|
+
useEffect(function () {
|
|
69
|
+
var observer = new IntersectionObserver(handleObserver, {
|
|
70
|
+
root: null,
|
|
71
|
+
rootMargin: rootMargin,
|
|
72
|
+
threshold: threshold
|
|
73
|
+
});
|
|
74
|
+
if (triggerRef.current) {
|
|
75
|
+
observer.observe(triggerRef.current);
|
|
76
|
+
}
|
|
77
|
+
observerRef.current = observer;
|
|
78
|
+
return function () {
|
|
79
|
+
var _observerRef$current;
|
|
80
|
+
(_observerRef$current = observerRef.current) === null || _observerRef$current === void 0 || _observerRef$current.disconnect();
|
|
81
|
+
};
|
|
82
|
+
}, [handleObserver, rootMargin, threshold]);
|
|
83
|
+
return {
|
|
84
|
+
data: data,
|
|
85
|
+
items: items,
|
|
86
|
+
size: size,
|
|
87
|
+
setSize: setSize,
|
|
88
|
+
isValidating: isValidating,
|
|
89
|
+
isLoadingMore: isLoadingMore,
|
|
90
|
+
hasMore: hasMore,
|
|
91
|
+
error: error,
|
|
92
|
+
loadMore: loadMore,
|
|
93
|
+
triggerRef: triggerRef
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -318,7 +318,13 @@ export type TableMaxProps = {
|
|
|
318
318
|
totalDatas?: any[];
|
|
319
319
|
/**分页,每页多少条可选值 */
|
|
320
320
|
pageSizeOptions?: number[];
|
|
321
|
+
/**useMemo缓存row */
|
|
321
322
|
openMemo?: boolean;
|
|
323
|
+
/**动态筛选-全局配置所有列的列筛选下拉选的值 */
|
|
324
|
+
getDynamicFilterOptionsFn?: (filter: {
|
|
325
|
+
field: string;
|
|
326
|
+
opera: any;
|
|
327
|
+
}, field: string, value: any) => Promise<any>;
|
|
322
328
|
};
|
|
323
329
|
export interface TableMaxColumnType {
|
|
324
330
|
/**每一列的id是唯一的 */
|
|
@@ -345,6 +351,12 @@ export interface TableMaxColumnType {
|
|
|
345
351
|
value: any;
|
|
346
352
|
label: any;
|
|
347
353
|
}[];
|
|
354
|
+
/**列筛选时 动态接口获取的可选值 label指定字段 */
|
|
355
|
+
dynamicFilterOptionsLabelField?: string;
|
|
356
|
+
/**列筛选时 动态接口获取的可选值 label指定函数 */
|
|
357
|
+
dynamicFilterOptionsLabelFn?: Function;
|
|
358
|
+
/**列筛选时 动态接口获取的可选值 value指定字段 */
|
|
359
|
+
dynamicFilterOptionsValueField?: string;
|
|
348
360
|
/**通过该函数获取可选项 */
|
|
349
361
|
getFilterOptionsFn?: IGetOptionType;
|
|
350
362
|
/** 表头筛选组件SingleSelect/MultiSelect中,输入字符串时对可选项进行过滤,是否前端过滤,默认false */
|