@umituz/react-native-design-system 4.25.59 → 4.25.61
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 +1 -1
- package/src/atoms/AtomicTouchable.tsx +4 -1
- package/src/atoms/datepicker/components/DatePickerButton.tsx +3 -3
- package/src/atoms/input/components/InputIcon.tsx +1 -1
- package/src/atoms/input/hooks/useInputState.ts +3 -3
- package/src/atoms/picker/components/PickerModal.tsx +9 -6
- package/src/infinite-scroll/presentation/components/infinite-scroll-list.tsx +1 -0
- package/src/layouts/ScreenLayout/ScreenLayout.tsx +16 -10
- package/src/molecules/List/List.tsx +1 -0
- package/src/molecules/alerts/AlertContainer.tsx +8 -5
- package/src/molecules/alerts/AlertToast.tsx +7 -1
- package/src/molecules/alerts/hooks/useAlertAutoDismiss.ts +1 -1
- package/src/molecules/alerts/hooks/useAlertDismissHandler.ts +1 -1
- package/src/molecules/bottom-sheet/components/BottomSheet.tsx +3 -3
- package/src/molecules/calendar/infrastructure/stores/useCalendarEvents.ts +2 -2
- package/src/offline/infrastructure/events/NetworkEvents.ts +8 -2
- package/src/storage/presentation/hooks/useStorageState.ts +1 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-design-system",
|
|
3
|
-
"version": "4.25.
|
|
3
|
+
"version": "4.25.61",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive, safe area, exception, infinite scroll, UUID, image, timezone, offline, onboarding, and loading utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -32,7 +32,7 @@ export interface AtomicTouchableProps {
|
|
|
32
32
|
accessible?: boolean;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
const AtomicTouchableComponent: React.FC<AtomicTouchableProps> = ({
|
|
36
36
|
children,
|
|
37
37
|
onPress,
|
|
38
38
|
onLongPress,
|
|
@@ -75,3 +75,6 @@ export const AtomicTouchable: React.FC<AtomicTouchableProps> = ({
|
|
|
75
75
|
</TouchableOpacity>
|
|
76
76
|
);
|
|
77
77
|
};
|
|
78
|
+
|
|
79
|
+
export const AtomicTouchable = React.memo(AtomicTouchableComponent);
|
|
80
|
+
AtomicTouchableComponent.displayName = 'AtomicTouchable';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Extracted from AtomicDatePicker for better separation of concerns.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React from 'react';
|
|
8
|
+
import React, { useMemo } from 'react';
|
|
9
9
|
import {
|
|
10
10
|
View,
|
|
11
11
|
TouchableOpacity,
|
|
@@ -35,7 +35,7 @@ export const DatePickerButton: React.FC<DatePickerButtonProps> = ({
|
|
|
35
35
|
const tokens = useAppDesignTokens();
|
|
36
36
|
const calendarIcon = useIconName('calendar');
|
|
37
37
|
|
|
38
|
-
const buttonStyles = StyleSheet.create({
|
|
38
|
+
const buttonStyles = useMemo(() => StyleSheet.create({
|
|
39
39
|
container: {
|
|
40
40
|
flexDirection: 'row',
|
|
41
41
|
alignItems: 'center',
|
|
@@ -75,7 +75,7 @@ export const DatePickerButton: React.FC<DatePickerButtonProps> = ({
|
|
|
75
75
|
alignItems: 'center',
|
|
76
76
|
gap: tokens.spacing.xs,
|
|
77
77
|
},
|
|
78
|
-
});
|
|
78
|
+
}), [tokens]);
|
|
79
79
|
|
|
80
80
|
const containerStyle = [
|
|
81
81
|
buttonStyles.container,
|
|
@@ -23,7 +23,7 @@ export const InputIcon: React.FC<InputIconProps> = ({
|
|
|
23
23
|
|
|
24
24
|
if (onPress) {
|
|
25
25
|
return (
|
|
26
|
-
<Pressable onPress={onPress} style={style} testID={testID}>
|
|
26
|
+
<Pressable onPress={onPress} style={style} testID={testID} hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}>
|
|
27
27
|
<AtomicIcon name={name} customSize={size} customColor={color} />
|
|
28
28
|
</Pressable>
|
|
29
29
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useCallback, useEffect
|
|
1
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
interface UseInputStateProps {
|
|
4
4
|
value?: string;
|
|
@@ -45,7 +45,7 @@ export const useInputState = ({
|
|
|
45
45
|
const characterCount = localValue.length;
|
|
46
46
|
const isAtMaxLength = maxLength ? characterCount >= maxLength : false;
|
|
47
47
|
|
|
48
|
-
return
|
|
48
|
+
return {
|
|
49
49
|
localValue,
|
|
50
50
|
isFocused,
|
|
51
51
|
isPasswordVisible,
|
|
@@ -54,5 +54,5 @@ export const useInputState = ({
|
|
|
54
54
|
setIsFocused,
|
|
55
55
|
handleTextChange,
|
|
56
56
|
togglePasswordVisibility,
|
|
57
|
-
}
|
|
57
|
+
};
|
|
58
58
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* PickerModal - Selection modal for AtomicPicker
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
6
|
import { View, Modal, FlatList, TextInput, TouchableOpacity } from 'react-native';
|
|
7
7
|
import { useSafeAreaInsets } from '../../../safe-area';
|
|
8
8
|
import { useAppDesignTokens } from '../../../theme';
|
|
@@ -71,9 +71,9 @@ export const PickerModal: React.FC<PickerModalProps> = React.memo(({
|
|
|
71
71
|
emptyText: getEmptyStateTextStyles(tokens),
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
const isSelected = (value: string) => selectedValues?.includes(value) ?? false;
|
|
74
|
+
const isSelected = useCallback((value: string) => selectedValues?.includes(value) ?? false, [selectedValues]);
|
|
75
75
|
|
|
76
|
-
const renderOption = ({ item }: { item: PickerOption }) => {
|
|
76
|
+
const renderOption = useCallback(({ item }: { item: PickerOption }) => {
|
|
77
77
|
const selected = isSelected(item.value);
|
|
78
78
|
const disabled = item.disabled || false;
|
|
79
79
|
|
|
@@ -81,6 +81,9 @@ export const PickerModal: React.FC<PickerModalProps> = React.memo(({
|
|
|
81
81
|
<TouchableOpacity
|
|
82
82
|
onPress={() => !disabled && onSelect(item.value)}
|
|
83
83
|
disabled={disabled}
|
|
84
|
+
accessibilityRole="button"
|
|
85
|
+
accessibilityLabel={item.label}
|
|
86
|
+
accessibilityState={{ disabled, selected }}
|
|
84
87
|
testID={item.testID || `${testID}-option-${item.value}`}
|
|
85
88
|
style={getOptionContainerStyles(tokens, selected, disabled)}
|
|
86
89
|
>
|
|
@@ -92,7 +95,7 @@ export const PickerModal: React.FC<PickerModalProps> = React.memo(({
|
|
|
92
95
|
{selected && <AtomicIcon name={icons.checkCircle} size="md" color="primary" />}
|
|
93
96
|
</TouchableOpacity>
|
|
94
97
|
);
|
|
95
|
-
};
|
|
98
|
+
}, [isSelected, onSelect, tokens, testID]);
|
|
96
99
|
|
|
97
100
|
return (
|
|
98
101
|
<Modal visible={visible} animationType="none" transparent onRequestClose={onClose} testID={`${testID}-modal`} accessibilityViewIsModal={true}>
|
|
@@ -109,12 +112,12 @@ export const PickerModal: React.FC<PickerModalProps> = React.memo(({
|
|
|
109
112
|
<View style={styles.search}>
|
|
110
113
|
<AtomicIcon name={icons.search} size="sm" color="secondary" />
|
|
111
114
|
<TextInput value={searchQuery} onChangeText={onSearchChange} placeholder={searchPlaceholder} placeholderTextColor={tokens.colors.textSecondary} style={styles.searchInput} testID={`${testID}-search`} />
|
|
112
|
-
{searchQuery.length > 0 && <TouchableOpacity onPress={() => onSearchChange('')}><AtomicIcon name={icons.close} size="sm" color="secondary" /></TouchableOpacity>}
|
|
115
|
+
{searchQuery.length > 0 && <TouchableOpacity onPress={() => onSearchChange('')} hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }} accessibilityRole="button" accessibilityLabel="Clear search"><AtomicIcon name={icons.close} size="sm" color="secondary" /></TouchableOpacity>}
|
|
113
116
|
</View>
|
|
114
117
|
)}
|
|
115
118
|
|
|
116
119
|
{filteredOptions.length > 0 ? (
|
|
117
|
-
<FlatList data={filteredOptions} keyExtractor={(item: PickerOption) => item.value} renderItem={renderOption} showsVerticalScrollIndicator testID={`${testID}-list`} />
|
|
120
|
+
<FlatList data={filteredOptions} keyExtractor={(item: PickerOption) => item.value} renderItem={renderOption} showsVerticalScrollIndicator keyboardShouldPersistTaps="handled" testID={`${testID}-list`} />
|
|
118
121
|
) : (
|
|
119
122
|
<View style={styles.empty}>
|
|
120
123
|
<AtomicIcon name={icons.info} size="xl" color="secondary" />
|
|
@@ -103,6 +103,7 @@ function InfiniteScrollListComponent<T>({
|
|
|
103
103
|
onEndReachedThreshold={calculateEndReachedThreshold(config.threshold)}
|
|
104
104
|
onRefresh={refresh}
|
|
105
105
|
refreshing={state.isRefreshing}
|
|
106
|
+
keyboardShouldPersistTaps="handled"
|
|
106
107
|
ListHeaderComponent={ListHeaderComponent}
|
|
107
108
|
ListFooterComponent={
|
|
108
109
|
<>
|
|
@@ -67,16 +67,22 @@ export const ScreenLayout: React.FC<ScreenLayoutProps> = (props: ScreenLayoutPro
|
|
|
67
67
|
}
|
|
68
68
|
]}>
|
|
69
69
|
{header}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
{scrollable ? (
|
|
71
|
+
<ScrollView
|
|
72
|
+
style={styles.scrollView}
|
|
73
|
+
contentContainerStyle={[styles.scrollContent, contentContainerStyle]}
|
|
74
|
+
showsVerticalScrollIndicator={!hideScrollIndicator}
|
|
75
|
+
keyboardShouldPersistTaps="handled"
|
|
76
|
+
refreshControl={refreshControl}
|
|
77
|
+
nestedScrollEnabled
|
|
78
|
+
>
|
|
79
|
+
{children}
|
|
80
|
+
</ScrollView>
|
|
81
|
+
) : (
|
|
82
|
+
<View style={[styles.scrollView, styles.scrollContent, contentContainerStyle]}>
|
|
83
|
+
{children}
|
|
84
|
+
</View>
|
|
85
|
+
)}
|
|
80
86
|
{footer && (
|
|
81
87
|
<View style={{ paddingBottom }}>
|
|
82
88
|
{footer}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* AlertContainer Component
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
6
|
import { View, StyleSheet } from 'react-native';
|
|
7
7
|
import { useSafeAreaInsets } from '../../safe-area';
|
|
8
8
|
import { useAppDesignTokens } from '../../theme';
|
|
@@ -12,14 +12,14 @@ import { AlertBanner } from './AlertBanner';
|
|
|
12
12
|
import { AlertModal } from './AlertModal';
|
|
13
13
|
import { Alert, AlertMode } from './AlertTypes';
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const AlertContainerComponent: React.FC = () => {
|
|
16
16
|
const alerts = useAlertStore((state: { alerts: Alert[] }) => state.alerts);
|
|
17
17
|
const insets = useSafeAreaInsets();
|
|
18
18
|
const tokens = useAppDesignTokens();
|
|
19
19
|
|
|
20
|
-
const toasts = alerts.filter((a: Alert) => a.mode === AlertMode.TOAST);
|
|
21
|
-
const banners = alerts.filter((a: Alert) => a.mode === AlertMode.BANNER);
|
|
22
|
-
const modals = alerts.filter((a: Alert) => a.mode === AlertMode.MODAL);
|
|
20
|
+
const toasts = useMemo(() => alerts.filter((a: Alert) => a.mode === AlertMode.TOAST), [alerts]);
|
|
21
|
+
const banners = useMemo(() => alerts.filter((a: Alert) => a.mode === AlertMode.BANNER), [alerts]);
|
|
22
|
+
const modals = useMemo(() => alerts.filter((a: Alert) => a.mode === AlertMode.MODAL), [alerts]);
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<View style={styles.container} pointerEvents="box-none">
|
|
@@ -53,6 +53,9 @@ export const AlertContainer: React.FC = () => {
|
|
|
53
53
|
);
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
+
export const AlertContainer = React.memo(AlertContainerComponent);
|
|
57
|
+
AlertContainerComponent.displayName = 'AlertContainer';
|
|
58
|
+
|
|
56
59
|
const styles = StyleSheet.create({
|
|
57
60
|
container: {
|
|
58
61
|
...StyleSheet.absoluteFillObject,
|
|
@@ -86,11 +86,17 @@ export function AlertToast({ alert }: AlertToastProps) {
|
|
|
86
86
|
<Pressable
|
|
87
87
|
key={action.id}
|
|
88
88
|
onPress={async () => {
|
|
89
|
-
|
|
89
|
+
try {
|
|
90
|
+
await action.onPress();
|
|
91
|
+
} catch (e) {
|
|
92
|
+
if (__DEV__) console.error('[AlertToast] action.onPress failed', e);
|
|
93
|
+
}
|
|
90
94
|
if (action.closeOnPress ?? true) {
|
|
91
95
|
handleDismiss();
|
|
92
96
|
}
|
|
93
97
|
}}
|
|
98
|
+
accessibilityRole="button"
|
|
99
|
+
accessibilityLabel={action.label}
|
|
94
100
|
style={[
|
|
95
101
|
styles.actionButton,
|
|
96
102
|
{
|
|
@@ -15,7 +15,7 @@ export function useAlertDismissHandler(alert: Alert) {
|
|
|
15
15
|
const handleDismiss = useCallback(() => {
|
|
16
16
|
dismissAlert(alert.id);
|
|
17
17
|
alert.onDismiss?.();
|
|
18
|
-
}, [alert, dismissAlert]);
|
|
18
|
+
}, [alert.id, alert.onDismiss, dismissAlert]);
|
|
19
19
|
|
|
20
20
|
return handleDismiss;
|
|
21
21
|
}
|
|
@@ -90,7 +90,7 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>((props,
|
|
|
90
90
|
content: {
|
|
91
91
|
flex: 1,
|
|
92
92
|
}
|
|
93
|
-
}), [sheetHeight, backgroundColor, tokens.colors, borderRadius, insets.bottom]);
|
|
93
|
+
}), [sheetHeight, backgroundColor, tokens.colors.modalOverlay, tokens.colors.surface, tokens.colors.border, borderRadius, insets.bottom]);
|
|
94
94
|
|
|
95
95
|
return (
|
|
96
96
|
<Modal
|
|
@@ -101,9 +101,9 @@ export const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>((props,
|
|
|
101
101
|
statusBarTranslucent
|
|
102
102
|
accessibilityViewIsModal={true}
|
|
103
103
|
>
|
|
104
|
-
<Pressable style={styles.overlay} onPress={dismiss}>
|
|
104
|
+
<Pressable style={styles.overlay} onPress={dismiss} accessibilityLabel="Close" accessibilityRole="button">
|
|
105
105
|
<View style={styles.container}>
|
|
106
|
-
<Pressable onPress={(e) => e.stopPropagation()} style={styles.content}>
|
|
106
|
+
<Pressable onPress={(e) => e.stopPropagation()} style={styles.content} accessibilityRole="none">
|
|
107
107
|
<View style={styles.handle} />
|
|
108
108
|
{children}
|
|
109
109
|
</Pressable>
|
|
@@ -70,8 +70,8 @@ export const useCalendarEvents = create<CalendarEventsStore>()((set, get) => ({
|
|
|
70
70
|
if (validEvents.length > 0) {
|
|
71
71
|
const hydratedEvents = validEvents.map((event) => ({
|
|
72
72
|
...event,
|
|
73
|
-
createdAt: new Date(event.createdAt),
|
|
74
|
-
updatedAt: new Date(event.updatedAt),
|
|
73
|
+
createdAt: event.createdAt ? new Date(event.createdAt) : new Date(),
|
|
74
|
+
updatedAt: event.updatedAt ? new Date(event.updatedAt) : new Date(),
|
|
75
75
|
}));
|
|
76
76
|
set({ events: hydratedEvents, isLoading: false });
|
|
77
77
|
} else {
|
|
@@ -32,15 +32,21 @@ class NetworkEventEmitter implements NetworkEvents {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
emit(event: 'online' | 'offline' | 'change', state: NetworkState): void {
|
|
35
|
-
this.listeners.get(event)
|
|
35
|
+
const listeners = this.listeners.get(event);
|
|
36
|
+
if (!listeners) return;
|
|
37
|
+
|
|
38
|
+
const failedListeners: NetworkEventListener[] = [];
|
|
39
|
+
listeners.forEach((listener) => {
|
|
36
40
|
try {
|
|
37
41
|
listener(state);
|
|
38
42
|
} catch (_error) {
|
|
43
|
+
failedListeners.push(listener);
|
|
39
44
|
if (__DEV__) {
|
|
40
|
-
console.error('[DesignSystem]
|
|
45
|
+
console.error('[DesignSystem] NetworkEventEmitter: listener threw an error', _error);
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
});
|
|
49
|
+
failedListeners.forEach((listener) => listeners.delete(listener));
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
removeAllListeners(): void {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Combines React state with automatic storage persistence
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { useState, useCallback
|
|
8
|
+
import { useState, useCallback } from 'react';
|
|
9
9
|
import { storageRepository } from '../../infrastructure/repositories/AsyncStorageRepository';
|
|
10
10
|
import { unwrap } from '../../domain/entities/StorageResult';
|
|
11
11
|
import type { StorageKey } from '../../domain/value-objects/StorageKey';
|
|
@@ -42,13 +42,6 @@ export const useStorageState = <T>(
|
|
|
42
42
|
}
|
|
43
43
|
);
|
|
44
44
|
|
|
45
|
-
// Sync state with loaded data
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (data !== undefined && data !== null) {
|
|
48
|
-
setState(data);
|
|
49
|
-
}
|
|
50
|
-
}, [data]);
|
|
51
|
-
|
|
52
45
|
// Update state and persist to storage
|
|
53
46
|
const updateState = useCallback(
|
|
54
47
|
async (value: T) => {
|