fix: table filterDropdown should accept cssvar (#46314)

This commit is contained in:
MadCcc 2023-12-07 19:21:43 +08:00 committed by GitHub
parent 379a7692f9
commit fbe3a39389
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -202,6 +202,10 @@ const InternalTable = <RecordType extends AnyObject = AnyObject>(
const prefixCls = getPrefixCls('table', customizePrefixCls); const prefixCls = getPrefixCls('table', customizePrefixCls);
const dropdownPrefixCls = getPrefixCls('dropdown', customizeDropdownPrefixCls); const dropdownPrefixCls = getPrefixCls('dropdown', customizeDropdownPrefixCls);
const [, token] = useToken();
const rootCls = useCSSVarCls(prefixCls);
const [wrapCSSVar, hashId] = useStyle(prefixCls, rootCls);
const mergedExpandable: ExpandableConfig<RecordType> = { const mergedExpandable: ExpandableConfig<RecordType> = {
childrenColumnName: legacyChildrenColumnName, childrenColumnName: legacyChildrenColumnName,
expandIconColumnIndex, expandIconColumnIndex,
@ -349,6 +353,7 @@ const InternalTable = <RecordType extends AnyObject = AnyObject>(
mergedColumns, mergedColumns,
onFilterChange, onFilterChange,
getPopupContainer: getPopupContainer || getContextPopupContainer, getPopupContainer: getPopupContainer || getContextPopupContainer,
rootClassName: classNames(rootClassName, rootCls),
}); });
const mergedData = getFilterData(sortedData, filterStates); const mergedData = getFilterData(sortedData, filterStates);
@ -538,10 +543,6 @@ const InternalTable = <RecordType extends AnyObject = AnyObject>(
}; };
} }
const [, token] = useToken();
const rootCls = useCSSVarCls(prefixCls);
const [wrapCSSVar, hashId] = useStyle(prefixCls, rootCls);
const wrapperClassNames = classNames( const wrapperClassNames = classNames(
rootCls, rootCls,
`${prefixCls}-wrapper`, `${prefixCls}-wrapper`,

View File

@ -133,6 +133,7 @@ export interface FilterDropdownProps<RecordType> {
locale: TableLocale; locale: TableLocale;
getPopupContainer?: GetPopupContainer; getPopupContainer?: GetPopupContainer;
filterResetToDefaultFilteredValue?: boolean; filterResetToDefaultFilteredValue?: boolean;
rootClassName?: string;
} }
function wrapStringListType(keys?: FilterKey) { function wrapStringListType(keys?: FilterKey) {
@ -154,6 +155,7 @@ function FilterDropdown<RecordType>(props: FilterDropdownProps<RecordType>) {
locale, locale,
children, children,
getPopupContainer, getPopupContainer,
rootClassName,
} = props; } = props;
const { const {
@ -524,6 +526,7 @@ function FilterDropdown<RecordType>(props: FilterDropdownProps<RecordType>) {
onOpenChange={onVisibleChange} onOpenChange={onVisibleChange}
getPopupContainer={getPopupContainer} getPopupContainer={getPopupContainer}
placement={direction === 'rtl' ? 'bottomLeft' : 'bottomRight'} placement={direction === 'rtl' ? 'bottomLeft' : 'bottomRight'}
rootClassName={rootClassName}
> >
<span <span
role="button" role="button"

View File

@ -76,6 +76,7 @@ function injectFilter<RecordType>(
triggerFilter: (filterState: FilterState<RecordType>) => void, triggerFilter: (filterState: FilterState<RecordType>) => void,
getPopupContainer?: GetPopupContainer, getPopupContainer?: GetPopupContainer,
pos?: string, pos?: string,
rootClassName?: string,
): ColumnsType<RecordType> { ): ColumnsType<RecordType> {
return columns.map((column, index) => { return columns.map((column, index) => {
const columnPos = getColumnPos(index, pos); const columnPos = getColumnPos(index, pos);
@ -103,6 +104,7 @@ function injectFilter<RecordType>(
triggerFilter={triggerFilter} triggerFilter={triggerFilter}
locale={locale} locale={locale}
getPopupContainer={getPopupContainer} getPopupContainer={getPopupContainer}
rootClassName={rootClassName}
> >
{renderColumnTitle(column.title, renderProps)} {renderColumnTitle(column.title, renderProps)}
</FilterDropdown> </FilterDropdown>
@ -122,6 +124,7 @@ function injectFilter<RecordType>(
triggerFilter, triggerFilter,
getPopupContainer, getPopupContainer,
columnPos, columnPos,
rootClassName,
), ),
}; };
} }
@ -184,6 +187,7 @@ interface FilterConfig<RecordType> {
filterStates: FilterState<RecordType>[], filterStates: FilterState<RecordType>[],
) => void; ) => void;
getPopupContainer?: GetPopupContainer; getPopupContainer?: GetPopupContainer;
rootClassName?: string;
} }
const getMergedColumns = <RecordType extends unknown>( const getMergedColumns = <RecordType extends unknown>(
@ -203,6 +207,7 @@ function useFilter<RecordType>({
onFilterChange, onFilterChange,
getPopupContainer, getPopupContainer,
locale: tableLocale, locale: tableLocale,
rootClassName,
}: FilterConfig<RecordType>): [ }: FilterConfig<RecordType>): [
TransformColumns<RecordType>, TransformColumns<RecordType>,
FilterState<RecordType>[], FilterState<RecordType>[],
@ -282,6 +287,8 @@ function useFilter<RecordType>({
tableLocale, tableLocale,
triggerFilter, triggerFilter,
getPopupContainer, getPopupContainer,
undefined,
rootClassName,
); );
return [transformColumns, mergedFilterStates, filters]; return [transformColumns, mergedFilterStates, filters];