@@ -20,7 +20,7 @@ import { forwardRef, useCallback, useMemo, useRef, useState } from "react";
20
20
import { Pressable , StyleSheet , Text , View } from "react-native" ;
21
21
import { P , match } from "ts-pattern" ;
22
22
import { Simplify } from "type-fest" ;
23
- import { DateFormat } from "../utils/i18n" ;
23
+ import { DateFormat , t } from "../utils/i18n" ;
24
24
import { DatePickerDate , DatePickerModal } from "./DatePicker" ;
25
25
26
26
const styles = StyleSheet . create ( {
@@ -204,7 +204,6 @@ type FilterCheckboxProps<T> = {
204
204
value : T [ ] | undefined ;
205
205
onPressRemove : ( ) => void ;
206
206
autoOpen ?: boolean ;
207
- checkAllLabel ?: string ;
208
207
} ;
209
208
210
209
type CheckAllItem = {
@@ -216,7 +215,6 @@ function FilterCheckbox<T>({
216
215
label,
217
216
items,
218
217
width,
219
- checkAllLabel,
220
218
value,
221
219
onValueChange,
222
220
onPressRemove,
@@ -232,23 +230,19 @@ function FilterCheckbox<T>({
232
230
[ items , valueSet ] ,
233
231
) ;
234
232
235
- const allChecked = checkAllLabel != null && valueSet . size === items . length ;
233
+ const allChecked = valueSet . size === items . length ;
236
234
237
235
const listItems = useMemo ( ( ) => {
238
- if ( checkAllLabel == null ) {
239
- return items ;
240
- }
241
-
242
236
const checked : CheckAllItem [ "checked" ] =
243
237
valueSet . size === 0 ? false : valueSet . size === items . length ? true : "mixed" ;
244
238
245
239
const checkAllItem : CheckAllItem = {
246
- label : checkAllLabel ,
240
+ label : t ( "common.filters.all" ) ,
247
241
checked,
248
242
} ;
249
243
250
244
return [ checkAllItem , ...items ] ;
251
- } , [ items , checkAllLabel , valueSet ] ) ;
245
+ } , [ items , valueSet ] ) ;
252
246
253
247
return (
254
248
< View style = { styles . container } >
@@ -258,7 +252,9 @@ function FilterCheckbox<T>({
258
252
ref = { inputRef }
259
253
onPressRemove = { onPressRemove }
260
254
isActive = { visible }
261
- value = { allChecked ? checkAllLabel : currentValue . map ( item => item . label ) . join ( ", " ) }
255
+ value = {
256
+ allChecked ? t ( "common.filters.all" ) : currentValue . map ( item => item . label ) . join ( ", " )
257
+ }
262
258
/>
263
259
264
260
< Popover
@@ -487,7 +483,6 @@ export type FilterCheckboxDef<T> = {
487
483
label : string ;
488
484
items : Item < T > [ ] ;
489
485
width ?: number ;
490
- checkAllLabel ?: string ;
491
486
} ;
492
487
493
488
export type FilterRadioDef < T > = {
@@ -592,12 +587,11 @@ export const FiltersStack = <T extends FiltersDefinition>({
592
587
onValueChange = { value => onChangeFilters ( { ...filters , [ filterName ] : value } ) }
593
588
/>
594
589
) )
595
- . with ( { type : "checkbox" } , ( { type, label, items, width, checkAllLabel } ) => (
590
+ . with ( { type : "checkbox" } , ( { type, label, items, width } ) => (
596
591
< FilterCheckbox
597
592
label = { label }
598
593
items = { items }
599
594
width = { width }
600
- checkAllLabel = { checkAllLabel }
601
595
autoOpen = { lastOpenedFilter === filterName }
602
596
value = { getFilterValue ( type , filters , filterName ) }
603
597
onValueChange = { value => onChangeFilters ( { ...filters , [ filterName ] : value } ) }
0 commit comments