Skip to content

Commit dfba27b

Browse files
committed
Remove checkAllLabel
1 parent c6c3881 commit dfba27b

File tree

10 files changed

+24
-15
lines changed

10 files changed

+24
-15
lines changed

packages/shared-business/__stories__/Filters.stories.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ const status: FilterCheckboxDef<
2828
> = {
2929
type: "checkbox",
3030
label: "Status",
31-
checkAllLabel: "All",
3231
items: [
3332
{ label: "Accepted", value: "Accepted" },
3433
{ label: "Canceled", value: "Canceled" },

packages/shared-business/src/components/Filters.tsx

+8-14
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { forwardRef, useCallback, useMemo, useRef, useState } from "react";
2020
import { Pressable, StyleSheet, Text, View } from "react-native";
2121
import { P, match } from "ts-pattern";
2222
import { Simplify } from "type-fest";
23-
import { DateFormat } from "../utils/i18n";
23+
import { DateFormat, t } from "../utils/i18n";
2424
import { DatePickerDate, DatePickerModal } from "./DatePicker";
2525

2626
const styles = StyleSheet.create({
@@ -204,7 +204,6 @@ type FilterCheckboxProps<T> = {
204204
value: T[] | undefined;
205205
onPressRemove: () => void;
206206
autoOpen?: boolean;
207-
checkAllLabel?: string;
208207
};
209208

210209
type CheckAllItem = {
@@ -216,7 +215,6 @@ function FilterCheckbox<T>({
216215
label,
217216
items,
218217
width,
219-
checkAllLabel,
220218
value,
221219
onValueChange,
222220
onPressRemove,
@@ -232,23 +230,19 @@ function FilterCheckbox<T>({
232230
[items, valueSet],
233231
);
234232

235-
const allChecked = checkAllLabel != null && valueSet.size === items.length;
233+
const allChecked = valueSet.size === items.length;
236234

237235
const listItems = useMemo(() => {
238-
if (checkAllLabel == null) {
239-
return items;
240-
}
241-
242236
const checked: CheckAllItem["checked"] =
243237
valueSet.size === 0 ? false : valueSet.size === items.length ? true : "mixed";
244238

245239
const checkAllItem: CheckAllItem = {
246-
label: checkAllLabel,
240+
label: t("common.filters.all"),
247241
checked,
248242
};
249243

250244
return [checkAllItem, ...items];
251-
}, [items, checkAllLabel, valueSet]);
245+
}, [items, valueSet]);
252246

253247
return (
254248
<View style={styles.container}>
@@ -258,7 +252,9 @@ function FilterCheckbox<T>({
258252
ref={inputRef}
259253
onPressRemove={onPressRemove}
260254
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+
}
262258
/>
263259

264260
<Popover
@@ -487,7 +483,6 @@ export type FilterCheckboxDef<T> = {
487483
label: string;
488484
items: Item<T>[];
489485
width?: number;
490-
checkAllLabel?: string;
491486
};
492487

493488
export type FilterRadioDef<T> = {
@@ -592,12 +587,11 @@ export const FiltersStack = <T extends FiltersDefinition>({
592587
onValueChange={value => onChangeFilters({ ...filters, [filterName]: value })}
593588
/>
594589
))
595-
.with({ type: "checkbox" }, ({ type, label, items, width, checkAllLabel }) => (
590+
.with({ type: "checkbox" }, ({ type, label, items, width }) => (
596591
<FilterCheckbox
597592
label={label}
598593
items={items}
599594
width={width}
600-
checkAllLabel={checkAllLabel}
601595
autoOpen={lastOpenedFilter === filterName}
602596
value={getFilterValue(type, filters, filterName)}
603597
onValueChange={value => onChangeFilters({ ...filters, [filterName]: value })}

packages/shared-business/src/locales/de.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"common.cancel": "Abbrechen",
2525
"common.close": "Schließen",
2626
"common.filters": "Filter",
27+
"common.filters.all": "Alle",
28+
"common.filters.apply": "Anwenden",
2729
"common.form.help.nbCharacters": "{nbCharacters} Zeichen",
2830
"common.form.help.nbDigits": "{nbDigits} Ziffern",
2931
"common.form.invalidTaxIdentificationNumber": "Diese Steueridentifikationsnummer ist ungültig",

packages/shared-business/src/locales/en.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"common.cancel": "Cancel",
2525
"common.close": "Close",
2626
"common.filters": "Filters",
27+
"common.filters.all": "All",
28+
"common.filters.apply": "Apply",
2729
"common.form.help.nbCharacters": "{nbCharacters} characters",
2830
"common.form.help.nbDigits": "{nbDigits} digits",
2931
"common.form.invalidTaxIdentificationNumber": "This tax identification number is invalid",

packages/shared-business/src/locales/es.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"common.cancel": "Cancelar",
2525
"common.close": "Cerrar",
2626
"common.filters": "Filtros",
27+
"common.filters.all": "Todo",
28+
"common.filters.apply": "Aplicar",
2729
"common.form.help.nbCharacters": "{nbCharacters} caracteres",
2830
"common.form.help.nbDigits": "{nbDigits} dígitos",
2931
"common.form.invalidTaxIdentificationNumber": "Este número de identificación fiscal no es válido",

packages/shared-business/src/locales/fi.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"common.cancel": "Peruuta",
2525
"common.close": "Sulje",
2626
"common.filters": "Suodattimet",
27+
"common.filters.all": "Kaikki",
28+
"common.filters.apply": "Käytä",
2729
"common.form.help.nbCharacters": "{nbCharacters} merkkiä",
2830
"common.form.help.nbDigits": "{nbDigits} numeroa",
2931
"common.form.invalidTaxIdentificationNumber": "Virheellinen verotunnistenumero",

packages/shared-business/src/locales/fr.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"common.cancel": "Annuler",
2525
"common.close": "Fermer",
2626
"common.filters": "Filtres",
27+
"common.filters.all": "Tout",
28+
"common.filters.apply": "Appliquer",
2729
"common.form.help.nbCharacters": "{nbCharacters} caractères",
2830
"common.form.help.nbDigits": "{nbDigits} chiffres",
2931
"common.form.invalidTaxIdentificationNumber": "Ce numéro d'identification fiscale n'est pas valide",

packages/shared-business/src/locales/it.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"common.cancel": "Annulla",
2525
"common.close": "Chiudi",
2626
"common.filters": "Filtri",
27+
"common.filters.all": "Tutti",
28+
"common.filters.apply": "Applica",
2729
"common.form.help.nbCharacters": "{nbCharacters} caratteri",
2830
"common.form.help.nbDigits": "{nbDigits} cifre",
2931
"common.form.invalidTaxIdentificationNumber": "Codice fiscale non valido",

packages/shared-business/src/locales/nl.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"common.cancel": "Annuleren",
2525
"common.close": "Sluiten",
2626
"common.filters": "Filters",
27+
"common.filters.all": "Alle",
28+
"common.filters.apply": "Toepassen",
2729
"common.form.help.nbCharacters": "{nbCharacters} tekens",
2830
"common.form.help.nbDigits": "{nbDigits} cijfers",
2931
"common.form.invalidTaxIdentificationNumber": "Dit fiscale identificatienummer is ongeldig",

packages/shared-business/src/locales/pt.json

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"common.cancel": "Cancelar",
2525
"common.close": "Fechar",
2626
"common.filters": "Filtros",
27+
"common.filters.all": "Todos",
28+
"common.filters.apply": "Aplicar",
2729
"common.form.help.nbCharacters": "{nbCharacters} caracteres",
2830
"common.form.help.nbDigits": "{nbDigits} dígitos",
2931
"common.form.invalidTaxIdentificationNumber": "Este número de identificação fiscal é inválido",

0 commit comments

Comments
 (0)