@arim-aisdc/public-components 2.3.6 → 2.3.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/TableHeader/Cell.js +2 -1
- package/dist/components/TableMax/TableHeader/index.less +9 -0
- package/dist/components/TableMax/components/ColumnFilterV2/DateRange/index.js +1 -1
- package/dist/components/TableMax/components/ColumnFilterV2/index.js +1 -0
- package/dist/components/TableMax/components/ColumnFilterV2/index.less +7 -0
- package/dist/components/TableMax/components/ColumnSort/customSortFns.d.ts +8 -8
- package/dist/components/TableMax/components/ColumnSort/index.d.ts +2 -1
- package/dist/components/TableMax/components/ColumnSort/index.js +7 -3
- package/dist/components/TableMax/components/ColumnSort/index.less +5 -0
- package/dist/components/TableMax/hooks/useColumnWidth.js +29 -9
- package/dist/hooks/useTranslation.js +2 -1
- package/package.json +1 -1
|
@@ -135,7 +135,8 @@ var Cell = function Cell(_ref) {
|
|
|
135
135
|
}), !cannotDragColumn.includes(header.column.id) ? /*#__PURE__*/_jsxs("div", {
|
|
136
136
|
className: "cell-right",
|
|
137
137
|
children: [canSorting && header.column.getCanSort() ? /*#__PURE__*/_jsx(Sort, {
|
|
138
|
-
sort: header.column.getIsSorted()
|
|
138
|
+
sort: header.column.getIsSorted(),
|
|
139
|
+
onClick: header.column.getToggleSortingHandler()
|
|
139
140
|
}) : null, canFilter && columnDef.enableColumnFilter !== false ? /*#__PURE__*/_jsx(ColumnFilter, {
|
|
140
141
|
column: header.column,
|
|
141
142
|
manualFiltering: manualFiltering
|
|
@@ -4,11 +4,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import { useTranslation } from "../../../../../hooks/useTranslation";
|
|
7
8
|
import { DatePicker } from 'antd';
|
|
8
9
|
import dayjs from 'dayjs';
|
|
9
10
|
import { defaultDateFormat } from "../index";
|
|
10
11
|
import "./index.less";
|
|
11
|
-
import { useTranslation } from "../../../../../hooks/useTranslation";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
var defaultRangePresets = [{
|
|
14
14
|
label: '最近7天',
|
|
@@ -129,6 +129,7 @@ export function ColumnFilter(_ref) {
|
|
|
129
129
|
setFilterPanelVisible(false);
|
|
130
130
|
}, []);
|
|
131
131
|
return /*#__PURE__*/_jsxs("div", {
|
|
132
|
+
className: "filter-icon-wrapper",
|
|
132
133
|
children: [/*#__PURE__*/_jsx("i", {
|
|
133
134
|
className: "iconfont-table icon-table-filter filter-icon ".concat(!!column.getFilterValue() ? 'height-light-filter' : ''),
|
|
134
135
|
onClick: onFilterIconClick
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
.filter-icon {
|
|
2
2
|
cursor: pointer;
|
|
3
|
+
display: none;
|
|
3
4
|
}
|
|
4
5
|
|
|
5
6
|
.height-light-filter {
|
|
6
7
|
color: @global-primary-color;
|
|
8
|
+
display: inline-block !important;
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
.filter-panel-wrapper {
|
|
@@ -21,3 +23,8 @@
|
|
|
21
23
|
padding: 8px 12px;
|
|
22
24
|
border-radius: 2px;
|
|
23
25
|
}
|
|
26
|
+
|
|
27
|
+
.filter-icon-wrapper {
|
|
28
|
+
line-height: 32px;
|
|
29
|
+
height: 32px;
|
|
30
|
+
}
|
|
@@ -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;
|
|
@@ -2,10 +2,12 @@ import "./index.less";
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
var Sort = function Sort(_ref) {
|
|
5
|
-
var sort = _ref.sort
|
|
5
|
+
var sort = _ref.sort,
|
|
6
|
+
onClick = _ref.onClick;
|
|
6
7
|
if (sort === 'asc') {
|
|
7
8
|
return /*#__PURE__*/_jsxs("span", {
|
|
8
|
-
className: "sort-flag",
|
|
9
|
+
className: "sort-flag show-sort-flag",
|
|
10
|
+
onClick: onClick,
|
|
9
11
|
children: [/*#__PURE__*/_jsx("i", {
|
|
10
12
|
className: "triangle-up triangle-up-red"
|
|
11
13
|
}), /*#__PURE__*/_jsx("i", {
|
|
@@ -14,7 +16,8 @@ var Sort = function Sort(_ref) {
|
|
|
14
16
|
});
|
|
15
17
|
} else if (sort === 'desc') {
|
|
16
18
|
return /*#__PURE__*/_jsxs("span", {
|
|
17
|
-
className: "sort-flag",
|
|
19
|
+
className: "sort-flag show-sort-flag",
|
|
20
|
+
onClick: onClick,
|
|
18
21
|
children: [/*#__PURE__*/_jsx("i", {
|
|
19
22
|
className: "triangle-up"
|
|
20
23
|
}), /*#__PURE__*/_jsx("i", {
|
|
@@ -24,6 +27,7 @@ var Sort = function Sort(_ref) {
|
|
|
24
27
|
}
|
|
25
28
|
return /*#__PURE__*/_jsxs("span", {
|
|
26
29
|
className: "sort-flag",
|
|
30
|
+
onClick: onClick,
|
|
27
31
|
children: [/*#__PURE__*/_jsx("i", {
|
|
28
32
|
className: "triangle-up"
|
|
29
33
|
}), /*#__PURE__*/_jsx("i", {
|
|
@@ -14,7 +14,8 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
14
14
|
import { getSizeInfo } from "../utils";
|
|
15
15
|
import { debounce } from 'lodash';
|
|
16
16
|
var CACHE_MAX_AGE = 1 * 60 * 60 * 1000; // 1小时
|
|
17
|
-
|
|
17
|
+
var defaultMinSize = 120;
|
|
18
|
+
var defaultMaxSize = 240;
|
|
18
19
|
export var useColumnWidth = function useColumnWidth(_ref) {
|
|
19
20
|
var tableContentRef = _ref.tableContentRef,
|
|
20
21
|
tableId = _ref.tableId,
|
|
@@ -28,7 +29,8 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
28
29
|
allColumnSizing: {},
|
|
29
30
|
//所有列的列宽
|
|
30
31
|
allColumnCount: 0,
|
|
31
|
-
tableContainerWidth: undefined
|
|
32
|
+
tableContainerWidth: undefined,
|
|
33
|
+
initColumnsSizeMap: {}
|
|
32
34
|
}),
|
|
33
35
|
_useState2 = _slicedToArray(_useState, 2),
|
|
34
36
|
state = _useState2[0],
|
|
@@ -43,7 +45,10 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
43
45
|
|
|
44
46
|
/**
|
|
45
47
|
* 处理容器宽度变化的逻辑
|
|
46
|
-
* 1
|
|
48
|
+
* 1.容器变小:
|
|
49
|
+
* 找到原始columns设置列宽度的第一列
|
|
50
|
+
* 如果当前列的宽度大于初始宽度,则按照容器变化的总宽度,除选择列和展开列外,其他列平分容器减小的宽度
|
|
51
|
+
* 如果当前列的宽度小于等于初始宽度,则列宽均不变
|
|
47
52
|
* 2.容器变大:
|
|
48
53
|
* 列宽之和大于容器宽度,不重新计算
|
|
49
54
|
* 列宽之和小于容器宽度,除选择列和展开列外,其他列平分 列宽之和与容器宽度的差值
|
|
@@ -63,7 +68,7 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
63
68
|
}, 0);
|
|
64
69
|
|
|
65
70
|
// 容器变大时的逻辑
|
|
66
|
-
if (newWidth > prevState.tableContainerWidth) {
|
|
71
|
+
if (prevState.tableContainerWidth > 0 && newWidth > prevState.tableContainerWidth) {
|
|
67
72
|
if (totalVisibleWidth < newWidth) {
|
|
68
73
|
// 计算剩余宽度
|
|
69
74
|
var remainWidth = newWidth - totalVisibleWidth - 10;
|
|
@@ -84,8 +89,23 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
84
89
|
});
|
|
85
90
|
}
|
|
86
91
|
}
|
|
92
|
+
} else if (prevState.tableContainerWidth > 0 && JSON.stringify(prevState.initColumnsSizeMap) !== '{}') {
|
|
93
|
+
// 容器变小时,重新计算
|
|
94
|
+
var reducedWidth = newWidth - totalVisibleWidth - 10;
|
|
95
|
+
var _unselectedCount = visibleColumns.length;
|
|
96
|
+
if (_unselectedCount > 0) {
|
|
97
|
+
var _averageWidth = reducedWidth / _unselectedCount;
|
|
98
|
+
var _newVisibleColumnsSizing = _objectSpread({}, prevState.columnSizing);
|
|
99
|
+
visibleColumns.forEach(function (key) {
|
|
100
|
+
_newVisibleColumnsSizing[key] = Math.max((_newVisibleColumnsSizing[key] || 0) + _averageWidth, Math.max(state.initColumnsSizeMap[visibleColumns[0]], defaultMinSize));
|
|
101
|
+
});
|
|
102
|
+
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
103
|
+
columnSizing: _newVisibleColumnsSizing,
|
|
104
|
+
allColumnSizing: _objectSpread(_objectSpread({}, prevState.allColumnSizing || {}), _newVisibleColumnsSizing),
|
|
105
|
+
tableContainerWidth: newWidth
|
|
106
|
+
});
|
|
107
|
+
}
|
|
87
108
|
}
|
|
88
|
-
// 容器变小时,列宽保持不变
|
|
89
109
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
90
110
|
tableContainerWidth: newWidth
|
|
91
111
|
});
|
|
@@ -185,8 +205,6 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
185
205
|
|
|
186
206
|
// 处理未设置宽度的列
|
|
187
207
|
if (remainColumnCount > 0) {
|
|
188
|
-
var defaultMinSize = 120;
|
|
189
|
-
var defaultMaxSize = 240;
|
|
190
208
|
var averageSize = Math.max(Math.min(remainTableContainerWidth / remainColumnCount, defaultMaxSize), defaultMinSize);
|
|
191
209
|
Object.keys(columnsSizeMap).forEach(function (key) {
|
|
192
210
|
if (!newColumnSizeMap[key]) {
|
|
@@ -243,7 +261,8 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
243
261
|
columnSizing: columnSizing,
|
|
244
262
|
allColumnCount: _newAllColumnCount,
|
|
245
263
|
allColumnSizing: _objectSpread(_objectSpread({}, _initColumnsSizeMap), columnSizing),
|
|
246
|
-
tableContainerWidth: prevState.tableContainerWidth
|
|
264
|
+
tableContainerWidth: prevState.tableContainerWidth,
|
|
265
|
+
initColumnsSizeMap: columnSizeMap
|
|
247
266
|
};
|
|
248
267
|
});
|
|
249
268
|
return;
|
|
@@ -269,7 +288,8 @@ export var useColumnWidth = function useColumnWidth(_ref) {
|
|
|
269
288
|
columnSizing: columnSizing,
|
|
270
289
|
allColumnSizing: _objectSpread(_objectSpread({}, initColumnsSizeMap), columnSizing),
|
|
271
290
|
allColumnCount: newAllColumnCount,
|
|
272
|
-
tableContainerWidth: prevState.tableContainerWidth
|
|
291
|
+
tableContainerWidth: prevState.tableContainerWidth,
|
|
292
|
+
initColumnsSizeMap: columnSizeMap
|
|
273
293
|
};
|
|
274
294
|
});
|
|
275
295
|
}, [columnVisibleConfig, tableId, tableKey, tableKeyPrefixCls, calculateColumnSizing]);
|
|
@@ -10,6 +10,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
import { FormItemType } from "../components/QueryFilter";
|
|
12
12
|
import { useConfig } from "../components/ConfigProvider";
|
|
13
|
+
import dayjs from 'dayjs';
|
|
13
14
|
function deepMerge(obj1, obj2) {
|
|
14
15
|
// 创建一个新对象,避免直接修改原始对象
|
|
15
16
|
var result = _objectSpread({}, obj1);
|
|
@@ -96,7 +97,7 @@ export var useTranslation = function useTranslation(locales) {
|
|
|
96
97
|
groupPrefix = _options$groupPrefix === void 0 ? "" : _options$groupPrefix;
|
|
97
98
|
var processArray = function processArray(array) {
|
|
98
99
|
return array.map(function (item) {
|
|
99
|
-
if (_typeof(item) === "object" && !Array.isArray(item)) {
|
|
100
|
+
if (_typeof(item) === "object" && !(item instanceof Date) && !(item instanceof dayjs) && !Array.isArray(item)) {
|
|
100
101
|
var newItem = _objectSpread({}, item);
|
|
101
102
|
if (fieldKey in newItem) {
|
|
102
103
|
// 如果有分组前缀,动态拼接键
|