@umituz/react-native-design-system 4.25.60 → 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/input/hooks/useInputState.ts +3 -3
- package/src/layouts/ScreenLayout/ScreenLayout.tsx +16 -10
- 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",
|
|
@@ -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
|
};
|
|
@@ -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) => {
|