@umituz/react-native-design-system 2.5.15 → 2.5.16
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/AtomicSwitch.tsx +83 -0
- package/src/atoms/AtomicTextArea.tsx +105 -0
- package/src/atoms/AtomicTouchable.tsx +42 -0
- package/src/atoms/index.ts +9 -0
- 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.16",
|
|
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",
|
|
@@ -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,105 @@
|
|
|
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
|
+
disabled?: boolean;
|
|
23
|
+
style?: ViewStyle;
|
|
24
|
+
testID?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const AtomicTextArea: React.FC<AtomicTextAreaProps> = ({
|
|
28
|
+
label,
|
|
29
|
+
value,
|
|
30
|
+
onChangeText,
|
|
31
|
+
placeholder,
|
|
32
|
+
helperText,
|
|
33
|
+
errorText,
|
|
34
|
+
maxLength,
|
|
35
|
+
numberOfLines = 4,
|
|
36
|
+
disabled = false,
|
|
37
|
+
style,
|
|
38
|
+
testID,
|
|
39
|
+
}) => {
|
|
40
|
+
const tokens = useAppDesignTokens();
|
|
41
|
+
const hasError = !!errorText;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<View style={[styles.container, style]} testID={testID}>
|
|
45
|
+
{label && (
|
|
46
|
+
<AtomicText
|
|
47
|
+
type="labelMedium"
|
|
48
|
+
style={[styles.label, { color: tokens.colors.textSecondary }]}
|
|
49
|
+
>
|
|
50
|
+
{label}
|
|
51
|
+
</AtomicText>
|
|
52
|
+
)}
|
|
53
|
+
<TextInput
|
|
54
|
+
value={value}
|
|
55
|
+
onChangeText={onChangeText}
|
|
56
|
+
placeholder={placeholder}
|
|
57
|
+
placeholderTextColor={tokens.colors.textTertiary}
|
|
58
|
+
maxLength={maxLength}
|
|
59
|
+
numberOfLines={numberOfLines}
|
|
60
|
+
multiline
|
|
61
|
+
editable={!disabled}
|
|
62
|
+
textAlignVertical="top"
|
|
63
|
+
style={[
|
|
64
|
+
styles.input,
|
|
65
|
+
{
|
|
66
|
+
backgroundColor: tokens.colors.surface,
|
|
67
|
+
borderColor: hasError ? tokens.colors.error : tokens.colors.border,
|
|
68
|
+
color: tokens.colors.textPrimary,
|
|
69
|
+
minHeight: numberOfLines * 24,
|
|
70
|
+
},
|
|
71
|
+
disabled && { opacity: 0.5 },
|
|
72
|
+
]}
|
|
73
|
+
/>
|
|
74
|
+
{(helperText || errorText) && (
|
|
75
|
+
<AtomicText
|
|
76
|
+
type="bodySmall"
|
|
77
|
+
style={[
|
|
78
|
+
styles.helperText,
|
|
79
|
+
{ color: hasError ? tokens.colors.error : tokens.colors.textSecondary },
|
|
80
|
+
]}
|
|
81
|
+
>
|
|
82
|
+
{errorText || helperText}
|
|
83
|
+
</AtomicText>
|
|
84
|
+
)}
|
|
85
|
+
</View>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const styles = StyleSheet.create({
|
|
90
|
+
container: {
|
|
91
|
+
marginBottom: 16,
|
|
92
|
+
},
|
|
93
|
+
label: {
|
|
94
|
+
marginBottom: 8,
|
|
95
|
+
},
|
|
96
|
+
input: {
|
|
97
|
+
borderWidth: 1,
|
|
98
|
+
borderRadius: 12,
|
|
99
|
+
padding: 12,
|
|
100
|
+
fontSize: 16,
|
|
101
|
+
},
|
|
102
|
+
helperText: {
|
|
103
|
+
marginTop: 4,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
@@ -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';
|
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
|
// =============================================================================
|