@@ -14,6 +14,7 @@ import type {
1414 VerticalAlign
1515} from '../../../enums/index.js' ;
1616import type { CommonProps } from '../../../types/index.js' ;
17+ import type { PopoverDomRef } from '../../../webComponents/Popover/index.js' ;
1718
1819export enum RenderColumnTypes {
1920 Filter = 'Filter' ,
@@ -60,7 +61,12 @@ export interface ColumnType extends Omit<AnalyticalTableColumnDefinition, 'id'>
6061 * @param props The props are added to the table instance
6162 */
6263 render ?: ( type : RenderColumnTypes | keyof typeof RenderColumnTypes , props : Record < string , any > ) => ReactNode ;
63- setFilter ?: ( val : string ) => void ;
64+ /**
65+ * Set the filter value for the current column.
66+ *
67+ * __Note:__ If set to `undefined`, the filter is removed.
68+ */
69+ setFilter ?: ( val : string | undefined ) => void ;
6470 sortDescFirst ?: boolean ;
6571 sortedIndex ?: number ;
6672 toggleHidden ?: ( hidden ?: boolean ) => void ;
@@ -139,7 +145,12 @@ export interface TableInstance {
139145 selectedFlatRows ?: RowType [ ] ;
140146 setAllFilters ?: ( filtersObjectArray : Record < string , any > [ ] ) => void ;
141147 setColumnOrder ?: any ;
142- setFilter ?: ( columnId : string , filterValue : string ) => void ;
148+ /**
149+ * Set the filter value for the defined column.
150+ *
151+ * __Note:__ If set to `undefined`, the filter is removed.
152+ */
153+ setFilter ?: ( columnId : string , filterValue : string | undefined ) => void ;
143154 setGlobalFilter ?: ( filterValue : string ) => void ;
144155 setGroupBy ?: ( columnIds : string [ ] ) => void ;
145156 setHiddenColumns ?: ( columnIds : string [ ] ) => void ;
@@ -323,6 +334,11 @@ export interface TableInstanceWithPopoverProps extends TableInstance {
323334 popoverProps : PopoverProps ;
324335}
325336
337+ export interface FilterProps {
338+ column : ColumnType ;
339+ popoverRef : MutableRefObject < PopoverDomRef > ;
340+ }
341+
326342export interface AnalyticalTableColumnDefinition {
327343 // base properties
328344 /**
@@ -403,7 +419,7 @@ export interface AnalyticalTableColumnDefinition {
403419 /**
404420 * Filter Component to be rendered in the Header.
405421 */
406- Filter ?: string | ComponentType < any > | ( ( props ?: any ) => ReactNode ) ;
422+ Filter ?: ComponentType < FilterProps > | ( ( props : FilterProps ) => ReactNode ) ;
407423 /**
408424 * Disable filters for this column.
409425 */
@@ -420,8 +436,10 @@ export interface AnalyticalTableColumnDefinition {
420436 * * `exactText`
421437 * * `exactTextCase`
422438 * * `equals`
439+ *
440+ * __Note:__ When the standard `Filter` component is used, the filter function is not triggered if the `filterValue` is empty, as the filter is then removed.
423441 */
424- filter ?: string | ( ( rows : any [ ] , columnIds : string [ ] , filterValue : string ) => any ) ;
442+ filter ?: string | ( ( rows : RowType [ ] , columnIds : string [ ] , filterValue : string ) => RowType [ ] ) ;
425443
426444 // useGlobalFilter
427445 /**
0 commit comments