@arim-aisdc/public-components 0.0.22 → 0.0.24
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/TableMax.js +9 -3
- package/dist/components/TableMax/components/ColumnSetting/index.js +45 -18
- package/dist/components/TableMax/type.d.ts +13 -1
- package/dist/components/TableMax/utils.d.ts +2 -0
- package/dist/components/TableMax/utils.js +32 -0
- package/package.json +2 -2
|
@@ -43,7 +43,7 @@ import customFilterFns from "./components/ColumnFilter/customFilterFns";
|
|
|
43
43
|
import ColumnSetting from "./components/ColumnSetting";
|
|
44
44
|
import customSortFns, { setDefaultSortFn } from "./components/ColumnSort/customSortFns";
|
|
45
45
|
import "./tableMax.less";
|
|
46
|
-
import { getSizeInfo, setInitColumnsSize, setRemainColumnsWidth } from "./utils";
|
|
46
|
+
import { getFormatFilters, getSizeInfo, setInitColumnsSize, setRemainColumnsWidth } from "./utils";
|
|
47
47
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
48
48
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
49
|
export var ColumnType = /*#__PURE__*/function (ColumnType) {
|
|
@@ -630,7 +630,13 @@ var TableMax = function TableMax(_ref) {
|
|
|
630
630
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
631
631
|
manualFiltering && manualFilteringChange && manualFilteringChange(columnFilters, tableId, filteredData, filteredRowModel);
|
|
632
632
|
if (onFilteringChange) {
|
|
633
|
-
onFilteringChange(
|
|
633
|
+
onFilteringChange({
|
|
634
|
+
tableId: tableId,
|
|
635
|
+
filteredData: filteredData,
|
|
636
|
+
filteredRowModel: filteredRowModel,
|
|
637
|
+
filters: columnFilters,
|
|
638
|
+
formatFilters: getFormatFilters(columns, columnFilters)
|
|
639
|
+
});
|
|
634
640
|
}
|
|
635
641
|
}, [JSON.stringify(columnFilters), manualFiltering, tableId]);
|
|
636
642
|
|
|
@@ -779,7 +785,7 @@ var TableMax = function TableMax(_ref) {
|
|
|
779
785
|
draggedRows: draggedRows,
|
|
780
786
|
updatedTableDatas: newTableDatas
|
|
781
787
|
});
|
|
782
|
-
}, [tableDatas]);
|
|
788
|
+
}, [tableDatas, rowOrderChange]);
|
|
783
789
|
|
|
784
790
|
// 把row数据填充到表单
|
|
785
791
|
var setFormData = function setFormData(rowOriginal) {
|
|
@@ -97,6 +97,23 @@ var SettingItem = function SettingItem(_ref) {
|
|
|
97
97
|
return [];
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
+
|
|
101
|
+
// 从左侧固定列中删除某一列
|
|
102
|
+
var deleteFromLeft = function deleteFromLeft() {
|
|
103
|
+
var left = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
104
|
+
var toDeleteId = arguments.length > 1 ? arguments[1] : undefined;
|
|
105
|
+
var newLeft = _toConsumableArray(left);
|
|
106
|
+
var index = newLeft.findIndex(function (item) {
|
|
107
|
+
return item === toDeleteId;
|
|
108
|
+
});
|
|
109
|
+
newLeft.splice(index, 1);
|
|
110
|
+
if (newLeft.length === [getRowCanExpand(), canSelection && !selectionWithoutChecked].filter(function (item) {
|
|
111
|
+
return item === true;
|
|
112
|
+
}).length) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
return newLeft;
|
|
116
|
+
};
|
|
100
117
|
var columnPinningChange = function columnPinningChange(value) {
|
|
101
118
|
console.log(value);
|
|
102
119
|
var _ref2 = table.getState().columnPinning || {
|
|
@@ -106,42 +123,52 @@ var SettingItem = function SettingItem(_ref) {
|
|
|
106
123
|
left = _ref2.left,
|
|
107
124
|
right = _ref2.right;
|
|
108
125
|
if (value === 'right') {
|
|
126
|
+
// 固定到右侧
|
|
109
127
|
right.unshift(column.id);
|
|
128
|
+
|
|
129
|
+
// 如果之前是固定在左侧了,就从left中删掉
|
|
130
|
+
var newLeft = left;
|
|
131
|
+
if (left && left.includes(column.id)) {
|
|
132
|
+
newLeft = deleteFromLeft(left, column.id);
|
|
133
|
+
}
|
|
110
134
|
table.setColumnPinning({
|
|
111
|
-
left:
|
|
135
|
+
left: newLeft,
|
|
112
136
|
right: cloneDeep(right)
|
|
113
137
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (value === 'left') {
|
|
138
|
+
} else if (value === 'left') {
|
|
139
|
+
// 固定到左侧
|
|
117
140
|
if (left.length === 0) {
|
|
118
|
-
column.id !== ColumnType.Expander && getRowCanExpand()
|
|
119
|
-
|
|
141
|
+
if (column.id !== ColumnType.Expander && getRowCanExpand()) {
|
|
142
|
+
left.push(ColumnType.Expander);
|
|
143
|
+
}
|
|
144
|
+
if (column.id !== ColumnType.Selection && canSelection && !selectionWithoutChecked) {
|
|
145
|
+
left.push(ColumnType.Selection);
|
|
146
|
+
}
|
|
120
147
|
}
|
|
121
148
|
left.push(column.id);
|
|
149
|
+
|
|
150
|
+
// 如果已经是固定在右侧了,就从右侧中删掉
|
|
151
|
+
if (right && right.includes(column.id)) {
|
|
152
|
+
var indexInRight = right.findIndex(function (item) {
|
|
153
|
+
return item === column.id;
|
|
154
|
+
});
|
|
155
|
+
right.splice(indexInRight, 1);
|
|
156
|
+
}
|
|
122
157
|
table.setColumnPinning({
|
|
123
158
|
left: cloneDeep(left),
|
|
124
|
-
right: right
|
|
159
|
+
right: cloneDeep(right)
|
|
125
160
|
});
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
if (value === false) {
|
|
161
|
+
} else if (value === false) {
|
|
129
162
|
if (right && right.includes(column.id)) {
|
|
130
163
|
column.pin(false);
|
|
131
164
|
return;
|
|
132
165
|
}
|
|
133
166
|
if (left && left.includes(column.id)) {
|
|
134
|
-
var
|
|
135
|
-
return item === column.id;
|
|
136
|
-
});
|
|
137
|
-
left.splice(index, 1);
|
|
167
|
+
var _newLeft = deleteFromLeft(left, column.id);
|
|
138
168
|
table.setColumnPinning({
|
|
139
|
-
left:
|
|
140
|
-
return item === true;
|
|
141
|
-
}).length ? [] : cloneDeep(left),
|
|
169
|
+
left: _newLeft,
|
|
142
170
|
right: right
|
|
143
171
|
});
|
|
144
|
-
return;
|
|
145
172
|
}
|
|
146
173
|
}
|
|
147
174
|
};
|
|
@@ -18,7 +18,9 @@ export type TableMaxProps = {
|
|
|
18
18
|
*/
|
|
19
19
|
/**用于缓存,要保证tableId的唯一性 */
|
|
20
20
|
tableId: string;
|
|
21
|
+
/**列配置 */
|
|
21
22
|
columns: TableMaxColumnType[];
|
|
23
|
+
/**表格数据 */
|
|
22
24
|
datas: any[];
|
|
23
25
|
theme?: string;
|
|
24
26
|
/**控制列显示 */
|
|
@@ -111,7 +113,15 @@ export type TableMaxProps = {
|
|
|
111
113
|
*/
|
|
112
114
|
getColumnFiltersData?: (columnFilters: ColumnFiltersState, tableId: string, filteredData: any[], filteredRowModel: RowModel<any>) => void;
|
|
113
115
|
/**筛选参数变化时触发的函数,前端筛选、后端筛选时都会触发 */
|
|
114
|
-
onFilteringChange?: (
|
|
116
|
+
onFilteringChange?: (params: {
|
|
117
|
+
tableId: string;
|
|
118
|
+
filteredData: any[];
|
|
119
|
+
filteredRowModel: RowModel<any>;
|
|
120
|
+
filters: ColumnFiltersState;
|
|
121
|
+
formatFilters: {
|
|
122
|
+
[key: string]: any;
|
|
123
|
+
};
|
|
124
|
+
}) => void;
|
|
115
125
|
/**自定义表格顶部所有的内容 */
|
|
116
126
|
renderOperate?: ReactNode;
|
|
117
127
|
/**表格顶部左侧标题,与renderOperateLeft互斥 */
|
|
@@ -254,6 +264,8 @@ export interface TableMaxColumnType {
|
|
|
254
264
|
format?: string;
|
|
255
265
|
picker?: 'date' | 'week' | 'month' | 'quarter' | 'year';
|
|
256
266
|
};
|
|
267
|
+
/**自定义当前列筛选值所使用的key,默认为当前列的id: { [ filterKey || id ]: value} */
|
|
268
|
+
filterKey?: string;
|
|
257
269
|
/**当前列是否可筛选 */
|
|
258
270
|
enableColumnFilter?: boolean;
|
|
259
271
|
/**自定义列的类名 */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ColumnFiltersState } from '@tanstack/react-table';
|
|
1
2
|
import { TableMaxColumnType } from './type';
|
|
2
3
|
export declare const getSizeInfo: (columns: TableMaxColumnType[]) => {
|
|
3
4
|
allCount: number;
|
|
@@ -19,3 +20,4 @@ export declare const getShadowInfo: (column: any, table: any) => {
|
|
|
19
20
|
isRightFirst: boolean;
|
|
20
21
|
isLeftLast: boolean;
|
|
21
22
|
};
|
|
23
|
+
export declare const getFormatFilters: (columns: TableMaxColumnType[], originFilters: ColumnFiltersState) => {};
|
|
@@ -95,4 +95,36 @@ export var getShadowInfo = function getShadowInfo(column, table) {
|
|
|
95
95
|
isRightFirst: isRightFirst,
|
|
96
96
|
isLeftLast: isLeftLast
|
|
97
97
|
};
|
|
98
|
+
};
|
|
99
|
+
export var getFormatFilters = function getFormatFilters(columns, originFilters) {
|
|
100
|
+
// console.log('getFormatFilters :>> ', columns, originFilters);
|
|
101
|
+
var formatFilters = {};
|
|
102
|
+
originFilters.forEach(function (filter) {
|
|
103
|
+
var id = filter.id,
|
|
104
|
+
value = filter.value;
|
|
105
|
+
var curColumn = columns.find(function (item) {
|
|
106
|
+
return item.id === id;
|
|
107
|
+
});
|
|
108
|
+
var filterType = curColumn.filterType,
|
|
109
|
+
filterKey = curColumn.filterKey;
|
|
110
|
+
// 优先取formattedFilterKey作为key
|
|
111
|
+
var formatKey = filterKey || id;
|
|
112
|
+
if (filterType === FilterType.Date) {
|
|
113
|
+
// 时间范围
|
|
114
|
+
formatFilters["".concat(formatKey, "From")] = value === null || value === void 0 ? void 0 : value.startDate;
|
|
115
|
+
formatFilters["".concat(formatKey, "To")] = value === null || value === void 0 ? void 0 : value.endDate;
|
|
116
|
+
} else if (filterType === FilterType.Integer) {
|
|
117
|
+
// 数字范围
|
|
118
|
+
formatFilters["".concat(formatKey, "From")] = value === null || value === void 0 ? void 0 : value[0];
|
|
119
|
+
formatFilters["".concat(formatKey, "To")] = value === null || value === void 0 ? void 0 : value[1];
|
|
120
|
+
} else if (filterType === FilterType.MultiSelect || !filterType) {
|
|
121
|
+
// 多选组件
|
|
122
|
+
formatFilters["".concat(formatKey, "List")] = value;
|
|
123
|
+
formatFilters[formatKey] = value;
|
|
124
|
+
} else {
|
|
125
|
+
// 其他
|
|
126
|
+
formatFilters[formatKey] = value;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return formatFilters;
|
|
98
130
|
};
|
package/package.json
CHANGED