@umituz/react-native-design-system 4.25.64 → 4.25.66
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/AtomicAvatar.tsx +2 -2
- package/src/layouts/Grid/Grid.tsx +6 -8
- package/src/layouts/ScreenHeader/ScreenHeader.tsx +4 -4
- package/src/molecules/alerts/AlertModal.tsx +93 -39
- package/src/molecules/alerts/AlertService.ts +4 -1
- package/src/molecules/alerts/AlertTypes.ts +1 -1
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.66",
|
|
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",
|
|
@@ -54,7 +54,7 @@ export interface AtomicAvatarProps {
|
|
|
54
54
|
// COMPONENT IMPLEMENTATION
|
|
55
55
|
// =============================================================================
|
|
56
56
|
|
|
57
|
-
export const AtomicAvatar: React.FC<AtomicAvatarProps> = ({
|
|
57
|
+
export const AtomicAvatar: React.FC<AtomicAvatarProps> = React.memo(({
|
|
58
58
|
source,
|
|
59
59
|
name,
|
|
60
60
|
size = 'md',
|
|
@@ -152,5 +152,5 @@ export const AtomicAvatar: React.FC<AtomicAvatarProps> = ({
|
|
|
152
152
|
)}
|
|
153
153
|
</View>
|
|
154
154
|
);
|
|
155
|
-
};
|
|
155
|
+
});
|
|
156
156
|
|
|
@@ -73,23 +73,21 @@ export const Grid: React.FC<GridProps> = ({
|
|
|
73
73
|
[responsiveGap]
|
|
74
74
|
);
|
|
75
75
|
|
|
76
|
+
const itemStyle = useMemo(() => ({
|
|
77
|
+
flex: columns ? 1 / columns - 0.01 : undefined,
|
|
78
|
+
minWidth: columns ? `${100 / columns - 1}%` as const : undefined,
|
|
79
|
+
}), [columns]);
|
|
80
|
+
|
|
76
81
|
// Convert children to array for mapping
|
|
77
82
|
const childArray = React.Children.toArray(children);
|
|
78
83
|
|
|
79
84
|
return (
|
|
80
85
|
<View style={[styles.container, style]} testID={testID}>
|
|
81
86
|
{childArray.map((child, index) => {
|
|
82
|
-
// Use child's key if available, otherwise use index
|
|
83
87
|
const key = (child as React.ReactElement).key || `grid-item-${index}`;
|
|
84
88
|
|
|
85
89
|
return (
|
|
86
|
-
<View
|
|
87
|
-
key={key}
|
|
88
|
-
style={{
|
|
89
|
-
flex: columns ? 1 / columns - 0.01 : undefined,
|
|
90
|
-
minWidth: columns ? `${100 / columns - 1}%` : undefined,
|
|
91
|
-
}}
|
|
92
|
-
>
|
|
90
|
+
<View key={key} style={itemStyle}>
|
|
93
91
|
{child}
|
|
94
92
|
</View>
|
|
95
93
|
);
|
|
@@ -97,7 +97,7 @@ const ScreenHeaderTitle: React.FC<{
|
|
|
97
97
|
title: string;
|
|
98
98
|
tokens: ReturnType<typeof useAppDesignTokens>;
|
|
99
99
|
testID?: string;
|
|
100
|
-
}> = ({ title, tokens, testID }) => (
|
|
100
|
+
}> = React.memo(({ title, tokens, testID }) => (
|
|
101
101
|
<View style={{ flex: 1, alignItems: 'center', paddingHorizontal: tokens.spacing.sm }}>
|
|
102
102
|
<AtomicText
|
|
103
103
|
type="headlineMedium"
|
|
@@ -114,15 +114,15 @@ const ScreenHeaderTitle: React.FC<{
|
|
|
114
114
|
{title}
|
|
115
115
|
</AtomicText>
|
|
116
116
|
</View>
|
|
117
|
-
);
|
|
117
|
+
));
|
|
118
118
|
|
|
119
119
|
const ScreenHeaderRightAction: React.FC<{
|
|
120
120
|
rightAction?: React.ReactNode;
|
|
121
|
-
}> = ({ rightAction }) => (
|
|
121
|
+
}> = React.memo(({ rightAction }) => (
|
|
122
122
|
<View style={{ width: 40, alignItems: 'flex-start' }}>
|
|
123
123
|
{rightAction || <View style={{ width: 40 }} />}
|
|
124
124
|
</View>
|
|
125
|
-
);
|
|
125
|
+
));
|
|
126
126
|
|
|
127
127
|
export const ScreenHeader: React.FC<ScreenHeaderProps> = ({
|
|
128
128
|
title,
|
|
@@ -4,24 +4,33 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { StyleSheet, View, Modal, Pressable } from 'react-native';
|
|
7
|
-
import { AtomicButton } from '../../atoms';
|
|
7
|
+
import { AtomicButton, AtomicText, AtomicIcon } from '../../atoms';
|
|
8
8
|
import { useAppDesignTokens } from '../../theme';
|
|
9
|
-
import { Alert } from './AlertTypes';
|
|
9
|
+
import { Alert, AlertType } from './AlertTypes';
|
|
10
10
|
import { getAlertBackgroundColor } from './utils/alertUtils';
|
|
11
11
|
import { useAlertDismissHandler } from './hooks';
|
|
12
|
-
import { AlertContent } from './components';
|
|
13
12
|
|
|
14
13
|
interface AlertModalProps {
|
|
15
14
|
alert: Alert;
|
|
16
15
|
}
|
|
17
16
|
|
|
17
|
+
const getAlertIconName = (type: AlertType): string => {
|
|
18
|
+
switch (type) {
|
|
19
|
+
case AlertType.SUCCESS: return 'checkmark-circle';
|
|
20
|
+
case AlertType.ERROR: return 'alertCircle';
|
|
21
|
+
case AlertType.WARNING: return 'alertCircle';
|
|
22
|
+
case AlertType.INFO: return 'info';
|
|
23
|
+
default: return 'info';
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
18
27
|
export const AlertModal: React.FC<AlertModalProps> = ({ alert }) => {
|
|
19
28
|
const tokens = useAppDesignTokens();
|
|
20
|
-
|
|
21
|
-
// Use shared hook (replaces 8 lines of duplicate code)
|
|
22
29
|
const handleClose = useAlertDismissHandler(alert);
|
|
23
30
|
|
|
24
|
-
const
|
|
31
|
+
const accentColor = getAlertBackgroundColor(alert.type, tokens);
|
|
32
|
+
const iconName = getAlertIconName(alert.type);
|
|
33
|
+
const hasTwoActions = alert.actions.length === 2;
|
|
25
34
|
|
|
26
35
|
return (
|
|
27
36
|
<Modal
|
|
@@ -39,47 +48,73 @@ export const AlertModal: React.FC<AlertModalProps> = ({ alert }) => {
|
|
|
39
48
|
styles.modal,
|
|
40
49
|
{
|
|
41
50
|
backgroundColor: tokens.colors.backgroundPrimary,
|
|
42
|
-
borderRadius: tokens.borders.radius.
|
|
51
|
+
borderRadius: tokens.borders.radius.xl ?? 20,
|
|
43
52
|
borderWidth: 1,
|
|
44
53
|
borderColor: tokens.colors.border,
|
|
45
54
|
}
|
|
46
55
|
]}>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
{/* Icon circle */}
|
|
57
|
+
<View style={[
|
|
58
|
+
styles.iconCircle,
|
|
59
|
+
{ backgroundColor: accentColor + '22' }
|
|
60
|
+
]}>
|
|
61
|
+
<AtomicIcon
|
|
62
|
+
name={iconName}
|
|
63
|
+
customSize={36}
|
|
64
|
+
customColor={accentColor}
|
|
55
65
|
/>
|
|
56
66
|
</View>
|
|
57
67
|
|
|
58
|
-
|
|
68
|
+
{/* Title */}
|
|
69
|
+
<AtomicText
|
|
70
|
+
type="titleLarge"
|
|
71
|
+
style={[styles.title, { color: tokens.colors.textPrimary }]}
|
|
72
|
+
>
|
|
73
|
+
{alert.title}
|
|
74
|
+
</AtomicText>
|
|
75
|
+
|
|
76
|
+
{/* Message */}
|
|
77
|
+
{!!alert.message && (
|
|
78
|
+
<AtomicText
|
|
79
|
+
type="bodyMedium"
|
|
80
|
+
style={[styles.message, { color: tokens.colors.textSecondary }]}
|
|
81
|
+
>
|
|
82
|
+
{alert.message}
|
|
83
|
+
</AtomicText>
|
|
84
|
+
)}
|
|
59
85
|
|
|
60
|
-
|
|
61
|
-
|
|
86
|
+
{/* Actions */}
|
|
87
|
+
<View style={[
|
|
88
|
+
hasTwoActions ? styles.actionsRow : styles.actionsColumn,
|
|
89
|
+
{ marginTop: tokens.spacing.lg, gap: tokens.spacing.sm }
|
|
90
|
+
]}>
|
|
91
|
+
{alert.actions.length === 0 ? (
|
|
92
|
+
<AtomicButton
|
|
93
|
+
title="Close"
|
|
94
|
+
onPress={handleClose}
|
|
95
|
+
fullWidth
|
|
96
|
+
/>
|
|
97
|
+
) : (
|
|
98
|
+
alert.actions.map((action, index) => (
|
|
62
99
|
<AtomicButton
|
|
63
|
-
key={action.id}
|
|
100
|
+
key={action.id ?? String(index)}
|
|
64
101
|
title={action.label}
|
|
65
|
-
variant={
|
|
102
|
+
variant={
|
|
103
|
+
action.style === 'destructive' ? 'danger'
|
|
104
|
+
: action.style === 'secondary' ? 'outline'
|
|
105
|
+
: 'primary'
|
|
106
|
+
}
|
|
66
107
|
onPress={async () => {
|
|
67
108
|
await action.onPress();
|
|
68
109
|
if (action.closeOnPress ?? true) {
|
|
69
110
|
handleClose();
|
|
70
111
|
}
|
|
71
112
|
}}
|
|
72
|
-
fullWidth
|
|
113
|
+
fullWidth={!hasTwoActions}
|
|
114
|
+
style={hasTwoActions ? styles.actionButtonHalf : undefined}
|
|
73
115
|
/>
|
|
74
|
-
))
|
|
75
|
-
|
|
76
|
-
<AtomicButton
|
|
77
|
-
title="Close"
|
|
78
|
-
onPress={handleClose}
|
|
79
|
-
fullWidth
|
|
80
|
-
/>
|
|
81
|
-
)}
|
|
82
|
-
</View>
|
|
116
|
+
))
|
|
117
|
+
)}
|
|
83
118
|
</View>
|
|
84
119
|
</View>
|
|
85
120
|
</View>
|
|
@@ -92,25 +127,44 @@ const styles = StyleSheet.create({
|
|
|
92
127
|
flex: 1,
|
|
93
128
|
justifyContent: 'center',
|
|
94
129
|
alignItems: 'center',
|
|
95
|
-
padding:
|
|
130
|
+
padding: 24,
|
|
96
131
|
},
|
|
97
132
|
backdrop: {
|
|
98
133
|
...StyleSheet.absoluteFillObject,
|
|
99
|
-
backgroundColor: 'rgba(0,0,0,0.
|
|
134
|
+
backgroundColor: 'rgba(0,0,0,0.55)',
|
|
100
135
|
},
|
|
101
136
|
modal: {
|
|
102
137
|
width: '100%',
|
|
103
|
-
maxWidth:
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
header: {
|
|
107
|
-
padding: 20,
|
|
138
|
+
maxWidth: 360,
|
|
139
|
+
padding: 28,
|
|
108
140
|
alignItems: 'center',
|
|
109
141
|
},
|
|
110
|
-
|
|
142
|
+
iconCircle: {
|
|
143
|
+
width: 76,
|
|
144
|
+
height: 76,
|
|
145
|
+
borderRadius: 38,
|
|
146
|
+
justifyContent: 'center',
|
|
111
147
|
alignItems: 'center',
|
|
148
|
+
marginBottom: 20,
|
|
149
|
+
},
|
|
150
|
+
title: {
|
|
151
|
+
fontWeight: '700',
|
|
152
|
+
textAlign: 'center',
|
|
153
|
+
marginBottom: 8,
|
|
112
154
|
},
|
|
113
|
-
|
|
155
|
+
message: {
|
|
156
|
+
textAlign: 'center',
|
|
157
|
+
lineHeight: 22,
|
|
158
|
+
opacity: 0.85,
|
|
159
|
+
},
|
|
160
|
+
actionsRow: {
|
|
161
|
+
flexDirection: 'row',
|
|
114
162
|
width: '100%',
|
|
115
163
|
},
|
|
164
|
+
actionsColumn: {
|
|
165
|
+
width: '100%',
|
|
166
|
+
},
|
|
167
|
+
actionButtonHalf: {
|
|
168
|
+
flex: 1,
|
|
169
|
+
},
|
|
116
170
|
});
|
|
@@ -30,7 +30,10 @@ export class AlertService {
|
|
|
30
30
|
message,
|
|
31
31
|
position: options?.position || defaultPosition,
|
|
32
32
|
icon: options?.icon,
|
|
33
|
-
actions: options?.actions
|
|
33
|
+
actions: options?.actions?.map(action => ({
|
|
34
|
+
id: generateUUID(),
|
|
35
|
+
...action,
|
|
36
|
+
})) || [],
|
|
34
37
|
dismissible: options?.dismissible ?? true,
|
|
35
38
|
duration: options?.duration,
|
|
36
39
|
onDismiss: options?.onDismiss,
|