1- import { isNumber , isUndefined } from 'lodash' ;
21import React , { useState } from 'react' ;
32import { useTranslation } from 'react-i18next' ;
43
@@ -11,7 +10,6 @@ export interface AppTableFilterProps extends Omit<React.HTMLAttributes<HTMLDivEl
1110 aFilterList ?: { label : string ; node : React . ReactElement ; isEmpty : boolean } [ ] ;
1211 aSearchValue ?: string ;
1312 aSearchPlaceholder ?: string ;
14- aLabelWidth ?: string | number ;
1513 onSearchValueChange ?: ( value : string ) => void ;
1614 onSearchClick ?: ( ) => void ;
1715 onResetClick ?: ( ) => void ;
@@ -22,7 +20,6 @@ export function AppTableFilter(props: AppTableFilterProps): JSX.Element | null {
2220 aFilterList,
2321 aSearchValue,
2422 aSearchPlaceholder,
25- aLabelWidth,
2623 onSearchValueChange,
2724 onSearchClick,
2825 onResetClick,
@@ -34,20 +31,7 @@ export function AppTableFilter(props: AppTableFilterProps): JSX.Element | null {
3431
3532 const [ searchValue , changeSearchValue ] = useDValue < string > ( '' , aSearchValue , onSearchValueChange ) ;
3633
37- const [ labelWidth , badgeValue ] = ( ( ) => {
38- let maxLength = 0 ;
39- let badgeValue = 0 ;
40- if ( aFilterList ) {
41- aFilterList . forEach ( ( item ) => {
42- maxLength = Math . max ( item . label . length , maxLength ) ;
43- if ( ! item . isEmpty ) {
44- badgeValue += 1 ;
45- }
46- } ) ;
47- }
48-
49- return [ isUndefined ( aLabelWidth ) ? maxLength + 1 + 'em' : aLabelWidth , badgeValue ] as const ;
50- } ) ( ) ;
34+ const badgeValue = aFilterList ? aFilterList . filter ( ( item ) => ! item . isEmpty ) . length : 0 ;
5135
5236 const [ showAdvancedSearch , setShowAdvancedSearch ] = useState ( false ) ;
5337
@@ -101,14 +85,8 @@ export function AppTableFilter(props: AppTableFilterProps): JSX.Element | null {
10185 < DSeparator > </ DSeparator >
10286 { aFilterList . map ( ( { label, node } ) => (
10387 < div key = { label } className = "app-table-filter__filter" >
104- < label className = "app-table-filter__filter-label" >
105- < div className = "app-colon" style = { { width : labelWidth } } >
106- { label }
107- </ div >
108- </ label >
109- { React . cloneElement ( node , {
110- style : { ...node . props . style , maxWidth : `calc(100% - ${ isNumber ( labelWidth ) ? labelWidth + 'px' : labelWidth } )` } ,
111- } ) }
88+ < label className = "app-table-filter__filter-label" > { label } </ label >
89+ { node }
11290 </ div >
11391 ) ) }
11492 </ >
0 commit comments