|
|
@ -187,6 +187,17 @@ export function getFilterData<RecordType>(
|
|
|
|
}, data);
|
|
|
|
}, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getMergedColumns<RecordType>(
|
|
|
|
|
|
|
|
rawMergedColumns: ColumnsType<RecordType>,
|
|
|
|
|
|
|
|
): ColumnsType<RecordType> {
|
|
|
|
|
|
|
|
return rawMergedColumns.flatMap(column => {
|
|
|
|
|
|
|
|
if ('children' in column) {
|
|
|
|
|
|
|
|
return [column, ...getMergedColumns(column.children || [])];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return [column];
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
interface FilterConfig<RecordType> {
|
|
|
|
interface FilterConfig<RecordType> {
|
|
|
|
prefixCls: Ref<string>;
|
|
|
|
prefixCls: Ref<string>;
|
|
|
|
dropdownPrefixCls: Ref<string>;
|
|
|
|
dropdownPrefixCls: Ref<string>;
|
|
|
@ -202,7 +213,7 @@ interface FilterConfig<RecordType> {
|
|
|
|
function useFilter<RecordType>({
|
|
|
|
function useFilter<RecordType>({
|
|
|
|
prefixCls,
|
|
|
|
prefixCls,
|
|
|
|
dropdownPrefixCls,
|
|
|
|
dropdownPrefixCls,
|
|
|
|
mergedColumns,
|
|
|
|
mergedColumns: rawMergedColumns,
|
|
|
|
locale,
|
|
|
|
locale,
|
|
|
|
onFilterChange,
|
|
|
|
onFilterChange,
|
|
|
|
getPopupContainer,
|
|
|
|
getPopupContainer,
|
|
|
@ -211,6 +222,8 @@ function useFilter<RecordType>({
|
|
|
|
Ref<FilterState<RecordType>[]>,
|
|
|
|
Ref<FilterState<RecordType>[]>,
|
|
|
|
Ref<Record<string, FilterValue | null>>,
|
|
|
|
Ref<Record<string, FilterValue | null>>,
|
|
|
|
] {
|
|
|
|
] {
|
|
|
|
|
|
|
|
const mergedColumns = computed(() => getMergedColumns(rawMergedColumns.value));
|
|
|
|
|
|
|
|
|
|
|
|
const [filterStates, setFilterStates] = useState<FilterState<RecordType>[]>(
|
|
|
|
const [filterStates, setFilterStates] = useState<FilterState<RecordType>[]>(
|
|
|
|
collectFilterStates(mergedColumns.value, true),
|
|
|
|
collectFilterStates(mergedColumns.value, true),
|
|
|
|
);
|
|
|
|
);
|
|
|
|