@umituz/react-native-design-system 2.5.21 → 2.5.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-design-system",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.23",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive and safe area utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -92,8 +92,10 @@ export const PickerModal: React.FC<PickerModalProps> = React.memo(({
|
|
|
92
92
|
const emptyStateStyles = getEmptyStateStyles(tokens);
|
|
93
93
|
const emptyStateTextStyles = getEmptyStateTextStyles(tokens);
|
|
94
94
|
|
|
95
|
+
const safeSelectedValues = selectedValues ?? [];
|
|
96
|
+
|
|
95
97
|
const isSelected = (optionValue: string): boolean => {
|
|
96
|
-
return
|
|
98
|
+
return safeSelectedValues.includes(optionValue);
|
|
97
99
|
};
|
|
98
100
|
|
|
99
101
|
const renderOption = ({ item }: { item: PickerOption }) => {
|
|
@@ -83,8 +83,10 @@ export const FilterBottomSheet = forwardRef<BottomSheetModalRef, FilterBottomShe
|
|
|
83
83
|
}
|
|
84
84
|
}), [tokens]);
|
|
85
85
|
|
|
86
|
+
const safeSelectedIds = selectedIds ?? [];
|
|
87
|
+
|
|
86
88
|
const renderOption = useCallback((option: FilterOption, categoryId: string) => {
|
|
87
|
-
const isSelected =
|
|
89
|
+
const isSelected = safeSelectedIds.includes(option.id);
|
|
88
90
|
|
|
89
91
|
return (
|
|
90
92
|
<TouchableOpacity
|
|
@@ -115,7 +117,7 @@ export const FilterBottomSheet = forwardRef<BottomSheetModalRef, FilterBottomShe
|
|
|
115
117
|
)}
|
|
116
118
|
</TouchableOpacity>
|
|
117
119
|
);
|
|
118
|
-
}, [
|
|
120
|
+
}, [safeSelectedIds, tokens, onFilterPress]);
|
|
119
121
|
|
|
120
122
|
const renderCategory = useCallback((category: FilterCategory) => (
|
|
121
123
|
<View key={category.id} style={styles.category}>
|
|
@@ -129,7 +131,7 @@ export const FilterBottomSheet = forwardRef<BottomSheetModalRef, FilterBottomShe
|
|
|
129
131
|
), [renderOption, styles]);
|
|
130
132
|
|
|
131
133
|
|
|
132
|
-
const hasActiveFilters = FilterUtils.hasActiveFilter(
|
|
134
|
+
const hasActiveFilters = FilterUtils.hasActiveFilter(safeSelectedIds, defaultId);
|
|
133
135
|
|
|
134
136
|
return (
|
|
135
137
|
<BottomSheetModal
|
|
@@ -34,7 +34,8 @@ export const FilterSheet: React.FC<FilterSheetProps> = ({
|
|
|
34
34
|
const tokens = useAppDesignTokens();
|
|
35
35
|
const insets = useSafeAreaInsets();
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const safeSelectedIds = selectedIds ?? [];
|
|
38
|
+
const hasActiveFilter = FilterUtils.hasActiveFilter(safeSelectedIds, defaultFilterId);
|
|
38
39
|
|
|
39
40
|
const handleFilterPressWithClose = useCallback((id: string) => {
|
|
40
41
|
onFilterPress(id);
|
|
@@ -61,7 +62,7 @@ export const FilterSheet: React.FC<FilterSheetProps> = ({
|
|
|
61
62
|
<FilterSheetOption
|
|
62
63
|
key={option.id}
|
|
63
64
|
option={option}
|
|
64
|
-
isSelected={
|
|
65
|
+
isSelected={safeSelectedIds.includes(option.id)}
|
|
65
66
|
onPress={handleFilterPressWithClose}
|
|
66
67
|
tokens={tokens}
|
|
67
68
|
/>
|
|
@@ -19,8 +19,9 @@ export interface FilterCategory {
|
|
|
19
19
|
|
|
20
20
|
export class FilterUtils {
|
|
21
21
|
static hasActiveFilter(selectedIds: string[], defaultId: string = "all"): boolean {
|
|
22
|
-
|
|
23
|
-
if (
|
|
22
|
+
const safeIds = selectedIds ?? [];
|
|
23
|
+
if (safeIds.length === 0) return false;
|
|
24
|
+
if (safeIds.length === 1 && safeIds[0] === defaultId) return false;
|
|
24
25
|
return true;
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -30,12 +31,13 @@ export class FilterUtils {
|
|
|
30
31
|
multiSelect: boolean = false,
|
|
31
32
|
defaultId: string = "all"
|
|
32
33
|
): string[] {
|
|
34
|
+
const safeIds = selectedIds ?? [];
|
|
33
35
|
if (filterId === defaultId) {
|
|
34
36
|
return [defaultId];
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
if (multiSelect) {
|
|
38
|
-
const newIds =
|
|
40
|
+
const newIds = safeIds.filter((id) => id !== defaultId);
|
|
39
41
|
if (newIds.includes(filterId)) {
|
|
40
42
|
const filtered = newIds.filter((id) => id !== filterId);
|
|
41
43
|
return filtered.length === 0 ? [defaultId] : filtered;
|