@umituz/react-native-design-system 2.5.15 → 2.5.17
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/AtomicButton.tsx +16 -6
- package/src/atoms/AtomicSwitch.tsx +83 -0
- package/src/atoms/AtomicTextArea.tsx +108 -0
- package/src/atoms/AtomicTouchable.tsx +42 -0
- package/src/atoms/index.ts +9 -0
- package/src/atoms/picker/types/index.ts +10 -10
- package/src/index.ts +6 -0
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.17",
|
|
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",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { StyleSheet, StyleProp, ViewStyle, TextStyle, TouchableOpacity, View } from 'react-native';
|
|
2
|
+
import { StyleSheet, StyleProp, ViewStyle, TextStyle, TouchableOpacity, View, ActivityIndicator } from 'react-native';
|
|
3
3
|
import { AtomicText } from './AtomicText';
|
|
4
4
|
import { AtomicIcon } from './AtomicIcon';
|
|
5
5
|
import { useAppDesignTokens } from '../theme';
|
|
@@ -15,6 +15,7 @@ export interface AtomicButtonProps {
|
|
|
15
15
|
variant?: ButtonVariant;
|
|
16
16
|
size?: ButtonSize;
|
|
17
17
|
disabled?: boolean;
|
|
18
|
+
loading?: boolean;
|
|
18
19
|
icon?: IconName;
|
|
19
20
|
fullWidth?: boolean;
|
|
20
21
|
style?: StyleProp<ViewStyle>;
|
|
@@ -30,6 +31,7 @@ export const AtomicButton: React.FC<AtomicButtonProps> = React.memo(({
|
|
|
30
31
|
variant = 'primary',
|
|
31
32
|
size = 'md',
|
|
32
33
|
disabled = false,
|
|
34
|
+
loading = false,
|
|
33
35
|
icon,
|
|
34
36
|
fullWidth = false,
|
|
35
37
|
style,
|
|
@@ -40,11 +42,13 @@ export const AtomicButton: React.FC<AtomicButtonProps> = React.memo(({
|
|
|
40
42
|
const tokens = useAppDesignTokens();
|
|
41
43
|
|
|
42
44
|
const handlePress = () => {
|
|
43
|
-
if (!disabled) {
|
|
45
|
+
if (!disabled && !loading) {
|
|
44
46
|
onPress();
|
|
45
47
|
}
|
|
46
48
|
};
|
|
47
49
|
|
|
50
|
+
const isDisabled = disabled || loading;
|
|
51
|
+
|
|
48
52
|
// Size configurations
|
|
49
53
|
const sizeConfig = {
|
|
50
54
|
sm: {
|
|
@@ -166,7 +170,7 @@ export const AtomicButton: React.FC<AtomicButtonProps> = React.memo(({
|
|
|
166
170
|
},
|
|
167
171
|
variantStyles.container,
|
|
168
172
|
fullWidth ? styles.fullWidth : undefined,
|
|
169
|
-
|
|
173
|
+
isDisabled ? styles.disabled : undefined,
|
|
170
174
|
style,
|
|
171
175
|
];
|
|
172
176
|
|
|
@@ -176,7 +180,7 @@ export const AtomicButton: React.FC<AtomicButtonProps> = React.memo(({
|
|
|
176
180
|
fontWeight: '600',
|
|
177
181
|
},
|
|
178
182
|
variantStyles.text,
|
|
179
|
-
|
|
183
|
+
isDisabled ? styles.disabledText : undefined,
|
|
180
184
|
textStyle,
|
|
181
185
|
];
|
|
182
186
|
|
|
@@ -189,11 +193,17 @@ export const AtomicButton: React.FC<AtomicButtonProps> = React.memo(({
|
|
|
189
193
|
style={containerStyle}
|
|
190
194
|
onPress={handlePress}
|
|
191
195
|
activeOpacity={activeOpacity}
|
|
192
|
-
disabled={
|
|
196
|
+
disabled={isDisabled}
|
|
193
197
|
testID={testID}
|
|
194
198
|
>
|
|
195
199
|
<View style={styles.content}>
|
|
196
|
-
{
|
|
200
|
+
{loading ? (
|
|
201
|
+
<ActivityIndicator
|
|
202
|
+
size="small"
|
|
203
|
+
color={iconColor as string}
|
|
204
|
+
style={styles.icon}
|
|
205
|
+
/>
|
|
206
|
+
) : showIcon ? (
|
|
197
207
|
<AtomicIcon
|
|
198
208
|
name={icon}
|
|
199
209
|
customSize={config.iconSize}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AtomicSwitch - Toggle Switch Component
|
|
3
|
+
*
|
|
4
|
+
* Atomic Design Level: ATOM
|
|
5
|
+
* Purpose: Boolean toggle across all apps
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { View, Switch, StyleSheet, ViewStyle } from 'react-native';
|
|
10
|
+
import { useAppDesignTokens } from '../theme';
|
|
11
|
+
import { AtomicText } from './AtomicText';
|
|
12
|
+
|
|
13
|
+
export interface AtomicSwitchProps {
|
|
14
|
+
label?: string;
|
|
15
|
+
value: boolean;
|
|
16
|
+
onValueChange: (value: boolean) => void;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
description?: string;
|
|
19
|
+
style?: ViewStyle;
|
|
20
|
+
testID?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const AtomicSwitch: React.FC<AtomicSwitchProps> = ({
|
|
24
|
+
label,
|
|
25
|
+
value,
|
|
26
|
+
onValueChange,
|
|
27
|
+
disabled = false,
|
|
28
|
+
description,
|
|
29
|
+
style,
|
|
30
|
+
testID,
|
|
31
|
+
}) => {
|
|
32
|
+
const tokens = useAppDesignTokens();
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<View style={[styles.container, style]} testID={testID}>
|
|
36
|
+
<View style={styles.row}>
|
|
37
|
+
{label && (
|
|
38
|
+
<View style={styles.labelContainer}>
|
|
39
|
+
<AtomicText
|
|
40
|
+
type="bodyMedium"
|
|
41
|
+
style={{ color: tokens.colors.textPrimary }}
|
|
42
|
+
>
|
|
43
|
+
{label}
|
|
44
|
+
</AtomicText>
|
|
45
|
+
{description && (
|
|
46
|
+
<AtomicText
|
|
47
|
+
type="bodySmall"
|
|
48
|
+
style={{ color: tokens.colors.textSecondary, marginTop: 2 }}
|
|
49
|
+
>
|
|
50
|
+
{description}
|
|
51
|
+
</AtomicText>
|
|
52
|
+
)}
|
|
53
|
+
</View>
|
|
54
|
+
)}
|
|
55
|
+
<Switch
|
|
56
|
+
value={value}
|
|
57
|
+
onValueChange={onValueChange}
|
|
58
|
+
disabled={disabled}
|
|
59
|
+
trackColor={{
|
|
60
|
+
false: tokens.colors.border,
|
|
61
|
+
true: tokens.colors.primary,
|
|
62
|
+
}}
|
|
63
|
+
thumbColor={value ? tokens.colors.onPrimary : tokens.colors.surface}
|
|
64
|
+
/>
|
|
65
|
+
</View>
|
|
66
|
+
</View>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const styles = StyleSheet.create({
|
|
71
|
+
container: {
|
|
72
|
+
marginBottom: 16,
|
|
73
|
+
},
|
|
74
|
+
row: {
|
|
75
|
+
flexDirection: 'row',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
justifyContent: 'space-between',
|
|
78
|
+
},
|
|
79
|
+
labelContainer: {
|
|
80
|
+
flex: 1,
|
|
81
|
+
marginRight: 16,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AtomicTextArea - Multiline Text Input Component
|
|
3
|
+
*
|
|
4
|
+
* Atomic Design Level: ATOM
|
|
5
|
+
* Purpose: Multiline text input across all apps
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { View, TextInput, StyleSheet, ViewStyle } from 'react-native';
|
|
10
|
+
import { useAppDesignTokens } from '../theme';
|
|
11
|
+
import { AtomicText } from './AtomicText';
|
|
12
|
+
|
|
13
|
+
export interface AtomicTextAreaProps {
|
|
14
|
+
label?: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
onChangeText?: (text: string) => void;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
helperText?: string;
|
|
19
|
+
errorText?: string;
|
|
20
|
+
maxLength?: number;
|
|
21
|
+
numberOfLines?: number;
|
|
22
|
+
rows?: number;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
style?: ViewStyle;
|
|
25
|
+
testID?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const AtomicTextArea: React.FC<AtomicTextAreaProps> = ({
|
|
29
|
+
label,
|
|
30
|
+
value,
|
|
31
|
+
onChangeText,
|
|
32
|
+
placeholder,
|
|
33
|
+
helperText,
|
|
34
|
+
errorText,
|
|
35
|
+
maxLength,
|
|
36
|
+
numberOfLines,
|
|
37
|
+
rows = 4,
|
|
38
|
+
disabled = false,
|
|
39
|
+
style,
|
|
40
|
+
testID,
|
|
41
|
+
}) => {
|
|
42
|
+
const lineCount = numberOfLines ?? rows;
|
|
43
|
+
const tokens = useAppDesignTokens();
|
|
44
|
+
const hasError = !!errorText;
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<View style={[styles.container, style]} testID={testID}>
|
|
48
|
+
{label && (
|
|
49
|
+
<AtomicText
|
|
50
|
+
type="labelMedium"
|
|
51
|
+
style={[styles.label, { color: tokens.colors.textSecondary }]}
|
|
52
|
+
>
|
|
53
|
+
{label}
|
|
54
|
+
</AtomicText>
|
|
55
|
+
)}
|
|
56
|
+
<TextInput
|
|
57
|
+
value={value}
|
|
58
|
+
onChangeText={onChangeText}
|
|
59
|
+
placeholder={placeholder}
|
|
60
|
+
placeholderTextColor={tokens.colors.textTertiary}
|
|
61
|
+
maxLength={maxLength}
|
|
62
|
+
numberOfLines={lineCount}
|
|
63
|
+
multiline
|
|
64
|
+
editable={!disabled}
|
|
65
|
+
textAlignVertical="top"
|
|
66
|
+
style={[
|
|
67
|
+
styles.input,
|
|
68
|
+
{
|
|
69
|
+
backgroundColor: tokens.colors.surface,
|
|
70
|
+
borderColor: hasError ? tokens.colors.error : tokens.colors.border,
|
|
71
|
+
color: tokens.colors.textPrimary,
|
|
72
|
+
minHeight: lineCount * 24,
|
|
73
|
+
},
|
|
74
|
+
disabled && { opacity: 0.5 },
|
|
75
|
+
]}
|
|
76
|
+
/>
|
|
77
|
+
{(helperText || errorText) && (
|
|
78
|
+
<AtomicText
|
|
79
|
+
type="bodySmall"
|
|
80
|
+
style={[
|
|
81
|
+
styles.helperText,
|
|
82
|
+
{ color: hasError ? tokens.colors.error : tokens.colors.textSecondary },
|
|
83
|
+
]}
|
|
84
|
+
>
|
|
85
|
+
{errorText || helperText}
|
|
86
|
+
</AtomicText>
|
|
87
|
+
)}
|
|
88
|
+
</View>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const styles = StyleSheet.create({
|
|
93
|
+
container: {
|
|
94
|
+
marginBottom: 16,
|
|
95
|
+
},
|
|
96
|
+
label: {
|
|
97
|
+
marginBottom: 8,
|
|
98
|
+
},
|
|
99
|
+
input: {
|
|
100
|
+
borderWidth: 1,
|
|
101
|
+
borderRadius: 12,
|
|
102
|
+
padding: 12,
|
|
103
|
+
fontSize: 16,
|
|
104
|
+
},
|
|
105
|
+
helperText: {
|
|
106
|
+
marginTop: 4,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AtomicTouchable - Touchable Component
|
|
3
|
+
*
|
|
4
|
+
* Atomic Design Level: ATOM
|
|
5
|
+
* Purpose: Touchable wrapper across all apps
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { TouchableOpacity, ViewStyle, StyleProp } from 'react-native';
|
|
10
|
+
|
|
11
|
+
export interface AtomicTouchableProps {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
onPress?: () => void;
|
|
14
|
+
onLongPress?: () => void;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
activeOpacity?: number;
|
|
17
|
+
style?: StyleProp<ViewStyle>;
|
|
18
|
+
testID?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const AtomicTouchable: React.FC<AtomicTouchableProps> = ({
|
|
22
|
+
children,
|
|
23
|
+
onPress,
|
|
24
|
+
onLongPress,
|
|
25
|
+
disabled = false,
|
|
26
|
+
activeOpacity = 0.7,
|
|
27
|
+
style,
|
|
28
|
+
testID,
|
|
29
|
+
}) => {
|
|
30
|
+
return (
|
|
31
|
+
<TouchableOpacity
|
|
32
|
+
onPress={onPress}
|
|
33
|
+
onLongPress={onLongPress}
|
|
34
|
+
disabled={disabled}
|
|
35
|
+
activeOpacity={activeOpacity}
|
|
36
|
+
style={style}
|
|
37
|
+
testID={testID}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</TouchableOpacity>
|
|
41
|
+
);
|
|
42
|
+
};
|
package/src/atoms/index.ts
CHANGED
|
@@ -99,3 +99,12 @@ export {
|
|
|
99
99
|
|
|
100
100
|
// Empty State
|
|
101
101
|
export { EmptyState, type EmptyStateProps } from './EmptyState';
|
|
102
|
+
|
|
103
|
+
// TextArea
|
|
104
|
+
export { AtomicTextArea, type AtomicTextAreaProps } from './AtomicTextArea';
|
|
105
|
+
|
|
106
|
+
// Switch
|
|
107
|
+
export { AtomicSwitch, type AtomicSwitchProps } from './AtomicSwitch';
|
|
108
|
+
|
|
109
|
+
// Touchable
|
|
110
|
+
export { AtomicTouchable, type AtomicTouchableProps } from './AtomicTouchable';
|
|
@@ -30,8 +30,8 @@ export interface AtomicPickerProps {
|
|
|
30
30
|
onChange: (value: string | string[]) => void;
|
|
31
31
|
options: PickerOption[];
|
|
32
32
|
label?: string;
|
|
33
|
-
/** Placeholder text -
|
|
34
|
-
placeholder
|
|
33
|
+
/** Placeholder text - pass translated string for i18n */
|
|
34
|
+
placeholder?: string;
|
|
35
35
|
error?: string;
|
|
36
36
|
disabled?: boolean;
|
|
37
37
|
multiple?: boolean;
|
|
@@ -41,14 +41,14 @@ export interface AtomicPickerProps {
|
|
|
41
41
|
color?: IconColor;
|
|
42
42
|
size?: PickerSize;
|
|
43
43
|
modalTitle?: string;
|
|
44
|
-
/** Empty state message -
|
|
45
|
-
emptyMessage
|
|
46
|
-
/** Search placeholder text -
|
|
47
|
-
searchPlaceholder
|
|
48
|
-
/** Clear button accessibility label -
|
|
49
|
-
clearAccessibilityLabel
|
|
50
|
-
/** Close button accessibility label -
|
|
51
|
-
closeAccessibilityLabel
|
|
44
|
+
/** Empty state message - pass translated string for i18n */
|
|
45
|
+
emptyMessage?: string;
|
|
46
|
+
/** Search placeholder text - pass translated string for i18n */
|
|
47
|
+
searchPlaceholder?: string;
|
|
48
|
+
/** Clear button accessibility label - pass translated string for i18n */
|
|
49
|
+
clearAccessibilityLabel?: string;
|
|
50
|
+
/** Close button accessibility label - pass translated string for i18n */
|
|
51
|
+
closeAccessibilityLabel?: string;
|
|
52
52
|
style?: ViewStyle | ViewStyle[];
|
|
53
53
|
labelStyle?: TextStyle | TextStyle[];
|
|
54
54
|
testID?: string;
|
package/src/index.ts
CHANGED
|
@@ -227,6 +227,12 @@ export {
|
|
|
227
227
|
type SpinnerSize,
|
|
228
228
|
type SpinnerColor,
|
|
229
229
|
type EmptyStateProps,
|
|
230
|
+
AtomicTextArea,
|
|
231
|
+
type AtomicTextAreaProps,
|
|
232
|
+
AtomicSwitch,
|
|
233
|
+
type AtomicSwitchProps,
|
|
234
|
+
AtomicTouchable,
|
|
235
|
+
type AtomicTouchableProps,
|
|
230
236
|
} from './atoms';
|
|
231
237
|
|
|
232
238
|
// =============================================================================
|