vpt-sebraeds 0.0.8 → 0.0.10
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/components/Avatar/index.jsx +14 -2
- package/components/BottomSheet/index.jsx +13 -15
- package/components/Input/index.jsx +99 -148
- package/dist/components/Avatar/index.d.ts.map +1 -1
- package/dist/components/Avatar/index.js +14 -2
- package/dist/components/BottomSheet/index.d.ts.map +1 -1
- package/dist/components/BottomSheet/index.js +10 -10
- package/dist/components/Input/index.d.ts +7 -12
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +71 -127
- package/package.json +1 -1
|
@@ -8,6 +8,12 @@ const Avatar = ({
|
|
|
8
8
|
name = '',
|
|
9
9
|
}) => {
|
|
10
10
|
const sizeOptions = {
|
|
11
|
+
Xlarge: {
|
|
12
|
+
container: styles.containerXlarge, // Novo estilo
|
|
13
|
+
image: { width: 109, height: 109, borderRadius: 54 },
|
|
14
|
+
initials: { width: 109, height: 109, borderRadius: 54, alignItems: 'center', justifyContent: 'center', backgroundColor: '#E3E9FF' },
|
|
15
|
+
text: { fontSize: 20, color: '#2A4FDA', fontWeight: '700' },
|
|
16
|
+
},
|
|
11
17
|
large: {
|
|
12
18
|
container: styles.containerLarge,
|
|
13
19
|
image: { width: 64, height: 64, borderRadius: 32 },
|
|
@@ -55,8 +61,8 @@ const Avatar = ({
|
|
|
55
61
|
{imageUrl ? (
|
|
56
62
|
<Image source={{ uri: imageUrl }} style={getImageStyle()} />
|
|
57
63
|
) : (
|
|
58
|
-
<View style={sizeOptions[size].initials}>
|
|
59
|
-
<Text style={sizeOptions[size].text}>
|
|
64
|
+
<View style={sizeOptions[size]?.initials || sizeOptions.medium.initials}>
|
|
65
|
+
<Text style={sizeOptions[size]?.text || sizeOptions.medium.text}>
|
|
60
66
|
{getInitials(name)}
|
|
61
67
|
</Text>
|
|
62
68
|
</View>
|
|
@@ -66,6 +72,12 @@ const Avatar = ({
|
|
|
66
72
|
};
|
|
67
73
|
|
|
68
74
|
const styles = StyleSheet.create({
|
|
75
|
+
containerXlarge: {
|
|
76
|
+
height: 109,
|
|
77
|
+
width: 109,
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
justifyContent: 'center',
|
|
80
|
+
},
|
|
69
81
|
containerLarge: {
|
|
70
82
|
height: 64,
|
|
71
83
|
width: 64,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useCallback } from 'react';
|
|
2
|
-
import { View, TouchableOpacity, FlatList, StyleSheet, Modal, Dimensions, Platform, ScrollView,
|
|
2
|
+
import { View, TouchableOpacity, FlatList, StyleSheet, Modal, Dimensions, Platform, ScrollView, Pressable } from 'react-native';
|
|
3
3
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'; // Adicione esta dependência
|
|
4
4
|
import SEIcon from '../SEIcon';
|
|
5
5
|
import SEText from '../SEText';
|
|
@@ -79,19 +79,15 @@ const BottomSheet = ({
|
|
|
79
79
|
onRequestClose={() => setIsOpen(false)}
|
|
80
80
|
statusBarTranslucent={Platform.OS === 'android'}
|
|
81
81
|
>
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
/>
|
|
92
|
-
{/* Conteúdo do modal acima do overlay para evitar interferência nos gestos */}
|
|
93
|
-
<View style={[modalContainerStyle, { zIndex: 1 }]}>
|
|
94
|
-
<View style={bottomSheetListStyle}>
|
|
82
|
+
<View style={overlayStyle}>
|
|
83
|
+
{/* Overlay absoluto atrás do conteúdo para capturar toques fora do modal */}
|
|
84
|
+
<Pressable
|
|
85
|
+
onPress={handleOverlayPress}
|
|
86
|
+
style={[StyleSheet.absoluteFill, { zIndex: 0 }]}
|
|
87
|
+
/>
|
|
88
|
+
{/* Conteúdo do modal acima do overlay para evitar interferência nos gestos */}
|
|
89
|
+
<View style={[modalContainerStyle, { zIndex: 1 }]}>
|
|
90
|
+
<View style={bottomSheetListStyle}>
|
|
95
91
|
{showHeader && (
|
|
96
92
|
<View style={[styles.modalHeader, fullScreen && { paddingTop: insets.top }]}>
|
|
97
93
|
<TouchableOpacity
|
|
@@ -125,6 +121,7 @@ const BottomSheet = ({
|
|
|
125
121
|
bounces={Platform.OS === 'ios'}
|
|
126
122
|
nestedScrollEnabled
|
|
127
123
|
scrollEventThrottle={16}
|
|
124
|
+
keyboardDismissMode="on-drag"
|
|
128
125
|
>
|
|
129
126
|
<View style={styles.contentContainer}>
|
|
130
127
|
{children}
|
|
@@ -133,7 +130,6 @@ const BottomSheet = ({
|
|
|
133
130
|
</View>
|
|
134
131
|
</View>
|
|
135
132
|
</View>
|
|
136
|
-
</KeyboardAvoidingView>
|
|
137
133
|
</Modal>
|
|
138
134
|
</View>
|
|
139
135
|
);
|
|
@@ -159,6 +155,7 @@ const styles = StyleSheet.create({
|
|
|
159
155
|
flex: 1,
|
|
160
156
|
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
161
157
|
justifyContent: 'flex-end',
|
|
158
|
+
alignItems: 'stretch',
|
|
162
159
|
},
|
|
163
160
|
modalContainer: {
|
|
164
161
|
display: 'flex',
|
|
@@ -173,6 +170,7 @@ const styles = StyleSheet.create({
|
|
|
173
170
|
borderTopLeftRadius: 20,
|
|
174
171
|
borderTopRightRadius: 20,
|
|
175
172
|
maxHeight: screenHeight * 0.8,
|
|
173
|
+
minHeight: 200,
|
|
176
174
|
},
|
|
177
175
|
modalHeader: {
|
|
178
176
|
width: '100%',
|
|
@@ -1,98 +1,83 @@
|
|
|
1
|
-
|
|
2
1
|
import React, { useCallback, useState } from 'react';
|
|
3
|
-
import { View,
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
import { View, TextInput, StyleSheet } from 'react-native';
|
|
3
|
+
import SEIcon from '~/superApp/UI/SEIcon';
|
|
4
|
+
import TooltipCard from '../TooltipCard';
|
|
5
|
+
import SEText from '../SEText';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Componente de Input controlado e reutilizável com suporte a máscaras e estados de validação.
|
|
9
|
+
* Usa React.forwardRef para permitir que o componente pai acesse o TextInput interno.
|
|
10
|
+
* @param {object} props - As propriedades do componente.
|
|
11
|
+
* @param {React.Ref} ref - A ref encaminhada para o TextInput.
|
|
12
|
+
*/
|
|
13
|
+
const Input = React.forwardRef((
|
|
14
|
+
{
|
|
15
|
+
label,
|
|
16
|
+
placeholder,
|
|
17
|
+
value,
|
|
18
|
+
onChangeText,
|
|
19
|
+
error,
|
|
20
|
+
success,
|
|
21
|
+
disabled,
|
|
22
|
+
supportText,
|
|
23
|
+
mask,
|
|
24
|
+
maskType,
|
|
25
|
+
tooltipProps, // <-- Adicione esta prop para receber o tooltip
|
|
26
|
+
...textInputProps
|
|
27
|
+
},
|
|
28
|
+
ref
|
|
29
|
+
) => {
|
|
18
30
|
const [isFocused, setIsFocused] = useState(false);
|
|
19
|
-
const [isFilled, setIsFilled] = useState(false);
|
|
20
|
-
const [inputValue, setInputValue] = useState(value || '');
|
|
21
31
|
|
|
22
32
|
const handleChangeText = (text) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
maskedText = applyMask(text, maskType);
|
|
33
|
+
const maskedText = applyMask(text, maskType);
|
|
34
|
+
if (onChangeText) {
|
|
35
|
+
onChangeText(maskedText);
|
|
27
36
|
}
|
|
28
|
-
|
|
29
|
-
setInputValue(maskedText);
|
|
30
|
-
setIsFilled(maskedText.length > 0);
|
|
31
|
-
if (onChangeText) onChangeText(maskedText);
|
|
32
37
|
};
|
|
33
38
|
|
|
34
39
|
const applyMask = useCallback((text, type) => {
|
|
35
|
-
if (!
|
|
36
|
-
|
|
40
|
+
if (!mask || !type || !text) return text;
|
|
37
41
|
const numbers = text.replace(/\D/g, '');
|
|
38
|
-
|
|
39
|
-
switch (type) {
|
|
42
|
+
switch (type.toLowerCase()) {
|
|
40
43
|
case 'cpf':
|
|
41
|
-
return
|
|
44
|
+
return numbers
|
|
45
|
+
.replace(/(\d{3})(\d)/, '$1.$2')
|
|
46
|
+
.replace(/(\d{3})(\d)/, '$1.$2')
|
|
47
|
+
.replace(/(\d{3})(\d{1,2})/, '$1-$2')
|
|
48
|
+
.slice(0, 14);
|
|
49
|
+
case 'cnpj':
|
|
50
|
+
return numbers
|
|
51
|
+
.replace(/(\d{2})(\d)/, '$1.$2')
|
|
52
|
+
.replace(/(\d{3})(\d)/, '$1.$2')
|
|
53
|
+
.replace(/(\d{3})(\d)/, '$1/$2')
|
|
54
|
+
.replace(/(\d{4})(\d{1,2})/, '$1-$2')
|
|
55
|
+
.replace(/(-\d{2})\d+?$/, '$1');
|
|
42
56
|
case 'cep':
|
|
43
|
-
return
|
|
57
|
+
return numbers.replace(/(\d{5})(\d)/, '$1-$2').slice(0, 9);
|
|
44
58
|
case 'phone':
|
|
45
|
-
|
|
59
|
+
if (numbers.length <= 10) {
|
|
60
|
+
return numbers
|
|
61
|
+
.replace(/(\d{2})(\d)/, '($1) $2')
|
|
62
|
+
.replace(/(\d{4})(\d)/, '$1-$2')
|
|
63
|
+
.slice(0, 14);
|
|
64
|
+
}
|
|
65
|
+
return numbers
|
|
66
|
+
.replace(/(\d{2})(\d)/, '($1) $2')
|
|
67
|
+
.replace(/(\d{5})(\d)/, '$1-$2')
|
|
68
|
+
.slice(0, 15);
|
|
46
69
|
case 'date':
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
70
|
+
return numbers
|
|
71
|
+
.replace(/(\d{2})(\d)/, '$1/$2')
|
|
72
|
+
.replace(/(\d{2})(\d)/, '$1/$2')
|
|
73
|
+
.slice(0, 10);
|
|
50
74
|
default:
|
|
51
75
|
return text;
|
|
52
76
|
}
|
|
53
77
|
}, [mask, maskType]);
|
|
54
78
|
|
|
55
|
-
const maskCPF = (value) => {
|
|
56
|
-
return value
|
|
57
|
-
.replace(/(\d{3})(\d)/, '$1.$2')
|
|
58
|
-
.replace(/(\d{3})(\d)/, '$1.$2')
|
|
59
|
-
.replace(/(\d{3})(\d{1,2})$/, '$1-$2');
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const maskCEP = (value) => {
|
|
63
|
-
return value.replace(/(\d{5})(\d)/, '$1-$2');
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const maskPhone = (value) => {
|
|
67
|
-
if (value.length <= 10) {
|
|
68
|
-
return value
|
|
69
|
-
.replace(/(\d{2})(\d)/, '($1) $2')
|
|
70
|
-
.replace(/(\d{4})(\d)/, '$1-$2');
|
|
71
|
-
} else {
|
|
72
|
-
return value
|
|
73
|
-
.replace(/(\d{2})(\d)/, '($1) $2')
|
|
74
|
-
.replace(/(\d{5})(\d)/, '$1-$2');
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const maskDate = (value) => {
|
|
79
|
-
return value
|
|
80
|
-
.replace(/(\d{2})(\d)/, '$1/$2')
|
|
81
|
-
.replace(/(\d{2})(\d)/, '$1/$2');
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const maskCurrency = (value) => {
|
|
85
|
-
if (!value) return '';
|
|
86
|
-
const numericValue = parseInt(value, 10) / 100;
|
|
87
|
-
return numericValue.toLocaleString('pt-BR', {
|
|
88
|
-
style: 'currency',
|
|
89
|
-
currency: 'BRL',
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
|
|
93
79
|
const getKeyboardType = () => {
|
|
94
80
|
if (!mask || !maskType) return 'default';
|
|
95
|
-
|
|
96
81
|
switch (maskType) {
|
|
97
82
|
case 'cpf':
|
|
98
83
|
case 'cep':
|
|
@@ -107,18 +92,12 @@ const Input = ({
|
|
|
107
92
|
|
|
108
93
|
const getMaxLength = () => {
|
|
109
94
|
if (!mask || !maskType) return undefined;
|
|
110
|
-
|
|
111
95
|
switch (maskType) {
|
|
112
|
-
case 'cpf':
|
|
113
|
-
|
|
114
|
-
case '
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return 15;
|
|
118
|
-
case 'date':
|
|
119
|
-
return 10;
|
|
120
|
-
default:
|
|
121
|
-
return undefined;
|
|
96
|
+
case 'cpf': return 14;
|
|
97
|
+
case 'cep': return 9;
|
|
98
|
+
case 'phone': return 15;
|
|
99
|
+
case 'date': return 10;
|
|
100
|
+
default: return undefined;
|
|
122
101
|
}
|
|
123
102
|
};
|
|
124
103
|
|
|
@@ -130,11 +109,11 @@ const Input = ({
|
|
|
130
109
|
return styles.container;
|
|
131
110
|
};
|
|
132
111
|
|
|
133
|
-
const
|
|
134
|
-
if (disabled) return
|
|
135
|
-
if (error) return
|
|
136
|
-
if (success) return
|
|
137
|
-
return
|
|
112
|
+
const getLabelColor = () => {
|
|
113
|
+
if (disabled) return '#BFBFBF';
|
|
114
|
+
if (error) return '#FF4D4F';
|
|
115
|
+
if (success) return '#52C41A';
|
|
116
|
+
return '#333333';
|
|
138
117
|
};
|
|
139
118
|
|
|
140
119
|
const getInputStyle = () => {
|
|
@@ -144,35 +123,47 @@ const Input = ({
|
|
|
144
123
|
return styles.input;
|
|
145
124
|
};
|
|
146
125
|
|
|
147
|
-
const
|
|
148
|
-
if (error) return
|
|
149
|
-
if (success) return
|
|
150
|
-
return
|
|
126
|
+
const getSupportTextColor = () => {
|
|
127
|
+
if (error) return '#FF4D4F';
|
|
128
|
+
if (success) return '#52C41A';
|
|
129
|
+
return '#4F7CFE';
|
|
151
130
|
};
|
|
152
131
|
|
|
153
132
|
return (
|
|
154
133
|
<View style={styles.wrapper}>
|
|
155
|
-
<
|
|
134
|
+
{label && <SEText type="ns-sm-body" color={getLabelColor()}>{label}</SEText>}
|
|
156
135
|
<View style={getContainerStyle()}>
|
|
157
136
|
<TextInput
|
|
137
|
+
ref={ref}
|
|
158
138
|
style={getInputStyle()}
|
|
159
139
|
placeholder={placeholder}
|
|
160
|
-
value={
|
|
140
|
+
value={value}
|
|
161
141
|
onChangeText={handleChangeText}
|
|
162
142
|
onFocus={() => setIsFocused(true)}
|
|
163
143
|
onBlur={() => setIsFocused(false)}
|
|
164
144
|
editable={!disabled}
|
|
165
145
|
keyboardType={getKeyboardType()}
|
|
166
146
|
maxLength={getMaxLength()}
|
|
147
|
+
placeholderTextColor="#BFBFBF"
|
|
148
|
+
{...textInputProps}
|
|
167
149
|
/>
|
|
168
|
-
{!disabled &&
|
|
169
|
-
|
|
170
|
-
|
|
150
|
+
{!disabled && tooltipProps ? (
|
|
151
|
+
<TooltipCard
|
|
152
|
+
{...tooltipProps}
|
|
153
|
+
trigger={
|
|
154
|
+
<SEIcon name="information-line" size={20} color="#687499" />
|
|
155
|
+
}
|
|
156
|
+
/>
|
|
157
|
+
) : !disabled && (
|
|
158
|
+
<SEIcon name="information-line" size={20} color="#687499" />
|
|
159
|
+
)}
|
|
160
|
+
{error && <SEIcon name="close-line" size={20} color="#FF4D4F" />}
|
|
161
|
+
{success && <SEIcon name="check-line" size={20} color="#52C41A" />}
|
|
171
162
|
</View>
|
|
172
|
-
{supportText && <
|
|
163
|
+
{supportText && <SEText type="ns-xs-body" color={getSupportTextColor()}>{supportText}</SEText>}
|
|
173
164
|
</View>
|
|
174
165
|
);
|
|
175
|
-
};
|
|
166
|
+
});
|
|
176
167
|
|
|
177
168
|
const styles = StyleSheet.create({
|
|
178
169
|
wrapper: {
|
|
@@ -182,10 +173,9 @@ const styles = StyleSheet.create({
|
|
|
182
173
|
container: {
|
|
183
174
|
flexDirection: 'row',
|
|
184
175
|
alignItems: 'center',
|
|
185
|
-
borderWidth:
|
|
186
|
-
borderColor: '#
|
|
176
|
+
borderWidth: 2,
|
|
177
|
+
borderColor: '#96ACFF',
|
|
187
178
|
borderRadius: 8,
|
|
188
|
-
backgroundColor: '#F5F8FF',
|
|
189
179
|
paddingHorizontal: 12,
|
|
190
180
|
},
|
|
191
181
|
containerFocused: {
|
|
@@ -194,56 +184,32 @@ const styles = StyleSheet.create({
|
|
|
194
184
|
borderWidth: 2,
|
|
195
185
|
borderColor: '#4F7CFE',
|
|
196
186
|
borderRadius: 8,
|
|
197
|
-
backgroundColor: '#F5F8FF',
|
|
198
187
|
paddingHorizontal: 11,
|
|
199
188
|
},
|
|
200
189
|
containerError: {
|
|
201
190
|
flexDirection: 'row',
|
|
202
191
|
alignItems: 'center',
|
|
203
|
-
borderWidth:
|
|
192
|
+
borderWidth: 2,
|
|
204
193
|
borderColor: '#FF4D4F',
|
|
205
194
|
borderRadius: 8,
|
|
206
|
-
backgroundColor: '#FFF1F0',
|
|
207
195
|
paddingHorizontal: 12,
|
|
208
196
|
},
|
|
209
197
|
containerSuccess: {
|
|
210
198
|
flexDirection: 'row',
|
|
211
199
|
alignItems: 'center',
|
|
212
|
-
borderWidth:
|
|
200
|
+
borderWidth: 2,
|
|
213
201
|
borderColor: '#52C41A',
|
|
214
202
|
borderRadius: 8,
|
|
215
|
-
backgroundColor: '#F6FFED',
|
|
216
203
|
paddingHorizontal: 12,
|
|
217
204
|
},
|
|
218
205
|
containerDisabled: {
|
|
219
206
|
flexDirection: 'row',
|
|
220
207
|
alignItems: 'center',
|
|
221
|
-
borderWidth:
|
|
208
|
+
borderWidth: 2,
|
|
222
209
|
borderColor: '#E6EEFF',
|
|
223
210
|
borderRadius: 8,
|
|
224
|
-
backgroundColor: '#F5F5F5',
|
|
225
211
|
paddingHorizontal: 12,
|
|
226
212
|
},
|
|
227
|
-
label: {
|
|
228
|
-
fontSize: 14,
|
|
229
|
-
color: '#333333',
|
|
230
|
-
fontFamily: 'Nunito Sans',
|
|
231
|
-
},
|
|
232
|
-
labelError: {
|
|
233
|
-
fontSize: 14,
|
|
234
|
-
color: '#FF4D4F',
|
|
235
|
-
fontFamily: 'Nunito Sans',
|
|
236
|
-
},
|
|
237
|
-
labelSuccess: {
|
|
238
|
-
fontSize: 14,
|
|
239
|
-
color: '#52C41A',
|
|
240
|
-
fontFamily: 'Nunito Sans',
|
|
241
|
-
},
|
|
242
|
-
labelDisabled: {
|
|
243
|
-
fontSize: 14,
|
|
244
|
-
color: '#BFBFBF',
|
|
245
|
-
fontFamily: 'Nunito Sans',
|
|
246
|
-
},
|
|
247
213
|
input: {
|
|
248
214
|
flex: 1,
|
|
249
215
|
height: 40,
|
|
@@ -272,21 +238,6 @@ const styles = StyleSheet.create({
|
|
|
272
238
|
fontSize: 14,
|
|
273
239
|
fontFamily: 'Nunito Sans',
|
|
274
240
|
},
|
|
275
|
-
supportText: {
|
|
276
|
-
fontSize: 12,
|
|
277
|
-
color: '#4F7CFE',
|
|
278
|
-
fontFamily: 'Nunito Sans',
|
|
279
|
-
},
|
|
280
|
-
supportTextError: {
|
|
281
|
-
fontSize: 12,
|
|
282
|
-
color: '#FF4D4F',
|
|
283
|
-
fontFamily: 'Nunito Sans',
|
|
284
|
-
},
|
|
285
|
-
supportTextSuccess: {
|
|
286
|
-
fontSize: 12,
|
|
287
|
-
color: '#52C41A',
|
|
288
|
-
fontFamily: 'Nunito Sans',
|
|
289
|
-
},
|
|
290
241
|
});
|
|
291
242
|
|
|
292
|
-
export default Input;
|
|
243
|
+
export default Input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Avatar/index.jsx"],"names":[],"mappings":";AAGA;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Avatar/index.jsx"],"names":[],"mappings":";AAGA;;;;;sBAoEC;kBAvEiB,OAAO"}
|
|
@@ -2,6 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { TouchableOpacity, Image, StyleSheet, Text, View } from 'react-native';
|
|
3
3
|
const Avatar = ({ size = 'medium', onPress, imageUrl, name = '', }) => {
|
|
4
4
|
const sizeOptions = {
|
|
5
|
+
Xlarge: {
|
|
6
|
+
container: styles.containerXlarge, // Novo estilo
|
|
7
|
+
image: { width: 109, height: 109, borderRadius: 54 },
|
|
8
|
+
initials: { width: 109, height: 109, borderRadius: 54, alignItems: 'center', justifyContent: 'center', backgroundColor: '#E3E9FF' },
|
|
9
|
+
text: { fontSize: 20, color: '#2A4FDA', fontWeight: '700' },
|
|
10
|
+
},
|
|
5
11
|
large: {
|
|
6
12
|
container: styles.containerLarge,
|
|
7
13
|
image: { width: 64, height: 64, borderRadius: 32 },
|
|
@@ -39,14 +45,20 @@ const Avatar = ({ size = 'medium', onPress, imageUrl, name = '', }) => {
|
|
|
39
45
|
return sizeOptions[size] ? sizeOptions[size].image : sizeOptions.medium.image;
|
|
40
46
|
};
|
|
41
47
|
return (<TouchableOpacity onPress={onPress} style={getContentStyle()}>
|
|
42
|
-
{imageUrl ? (<Image source={{ uri: imageUrl }} style={getImageStyle()}/>) : (<View style={sizeOptions[size].initials}>
|
|
43
|
-
<Text style={sizeOptions[size].text}>
|
|
48
|
+
{imageUrl ? (<Image source={{ uri: imageUrl }} style={getImageStyle()}/>) : (<View style={sizeOptions[size]?.initials || sizeOptions.medium.initials}>
|
|
49
|
+
<Text style={sizeOptions[size]?.text || sizeOptions.medium.text}>
|
|
44
50
|
{getInitials(name)}
|
|
45
51
|
</Text>
|
|
46
52
|
</View>)}
|
|
47
53
|
</TouchableOpacity>);
|
|
48
54
|
};
|
|
49
55
|
const styles = StyleSheet.create({
|
|
56
|
+
containerXlarge: {
|
|
57
|
+
height: 109,
|
|
58
|
+
width: 109,
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
justifyContent: 'center',
|
|
61
|
+
},
|
|
50
62
|
containerLarge: {
|
|
51
63
|
height: 64,
|
|
52
64
|
width: 64,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/BottomSheet/index.jsx"],"names":[],"mappings":";AAQA;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/BottomSheet/index.jsx"],"names":[],"mappings":";AAQA;;;;;;;;;;sBA+HC;kBAvI4C,OAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useCallback } from 'react';
|
|
2
|
-
import { View, TouchableOpacity, FlatList, StyleSheet, Modal, Dimensions, Platform, ScrollView,
|
|
2
|
+
import { View, TouchableOpacity, FlatList, StyleSheet, Modal, Dimensions, Platform, ScrollView, Pressable } from 'react-native';
|
|
3
3
|
import { useSafeAreaInsets } from 'react-native-safe-area-context'; // Adicione esta dependência
|
|
4
4
|
import SEIcon from '../SEIcon';
|
|
5
5
|
import SEText from '../SEText';
|
|
@@ -55,13 +55,12 @@ headerIcon = null, // Nova prop para o ícone no header
|
|
|
55
55
|
};
|
|
56
56
|
return (<View style={styles.wrapper}>
|
|
57
57
|
<Modal visible={isOpen} transparent={true} animationType={Platform.OS === 'ios' ? 'slide' : 'fade'} presentationStyle="overFullScreen" onRequestClose={() => setIsOpen(false)} statusBarTranslucent={Platform.OS === 'android'}>
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
<View style={
|
|
64
|
-
<View style={bottomSheetListStyle}>
|
|
58
|
+
<View style={overlayStyle}>
|
|
59
|
+
{/* Overlay absoluto atrás do conteúdo para capturar toques fora do modal */}
|
|
60
|
+
<Pressable onPress={handleOverlayPress} style={[StyleSheet.absoluteFill, { zIndex: 0 }]}/>
|
|
61
|
+
{/* Conteúdo do modal acima do overlay para evitar interferência nos gestos */}
|
|
62
|
+
<View style={[modalContainerStyle, { zIndex: 1 }]}>
|
|
63
|
+
<View style={bottomSheetListStyle}>
|
|
65
64
|
{showHeader && (<View style={[styles.modalHeader, fullScreen && { paddingTop: insets.top }]}>
|
|
66
65
|
<TouchableOpacity onPress={() => setIsOpen(false)} style={styles.closeButton}>
|
|
67
66
|
<SEIcon name="close-line" size={20} color="#666666"/>
|
|
@@ -76,7 +75,7 @@ headerIcon = null, // Nova prop para o ícone no header
|
|
|
76
75
|
{validSubtitle.length > 0 && (<SEText campuni style={styles.modalSubtitle}>{validSubtitle}</SEText>)}
|
|
77
76
|
</View>)}
|
|
78
77
|
|
|
79
|
-
<ScrollView showsVerticalScrollIndicator={true} contentContainerStyle={styles.scrollContent} style={scrollViewStyle} keyboardShouldPersistTaps="handled" bounces={Platform.OS === 'ios'} nestedScrollEnabled scrollEventThrottle={16}>
|
|
78
|
+
<ScrollView showsVerticalScrollIndicator={true} contentContainerStyle={styles.scrollContent} style={scrollViewStyle} keyboardShouldPersistTaps="handled" bounces={Platform.OS === 'ios'} nestedScrollEnabled scrollEventThrottle={16} keyboardDismissMode="on-drag">
|
|
80
79
|
<View style={styles.contentContainer}>
|
|
81
80
|
{children}
|
|
82
81
|
</View>
|
|
@@ -84,7 +83,6 @@ headerIcon = null, // Nova prop para o ícone no header
|
|
|
84
83
|
</View>
|
|
85
84
|
</View>
|
|
86
85
|
</View>
|
|
87
|
-
</KeyboardAvoidingView>
|
|
88
86
|
</Modal>
|
|
89
87
|
</View>);
|
|
90
88
|
};
|
|
@@ -108,6 +106,7 @@ const styles = StyleSheet.create({
|
|
|
108
106
|
flex: 1,
|
|
109
107
|
backgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
110
108
|
justifyContent: 'flex-end',
|
|
109
|
+
alignItems: 'stretch',
|
|
111
110
|
},
|
|
112
111
|
modalContainer: {
|
|
113
112
|
display: 'flex',
|
|
@@ -122,6 +121,7 @@ const styles = StyleSheet.create({
|
|
|
122
121
|
borderTopLeftRadius: 20,
|
|
123
122
|
borderTopRightRadius: 20,
|
|
124
123
|
maxHeight: screenHeight * 0.8,
|
|
124
|
+
minHeight: 200,
|
|
125
125
|
},
|
|
126
126
|
modalHeader: {
|
|
127
127
|
width: '100%',
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
export default Input;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
disabled: any;
|
|
10
|
-
supportText: any;
|
|
11
|
-
mask: any;
|
|
12
|
-
maskType: any;
|
|
13
|
-
}): React.JSX.Element;
|
|
2
|
+
/**
|
|
3
|
+
* Componente de Input controlado e reutilizável com suporte a máscaras e estados de validação.
|
|
4
|
+
* Usa React.forwardRef para permitir que o componente pai acesse o TextInput interno.
|
|
5
|
+
* @param {object} props - As propriedades do componente.
|
|
6
|
+
* @param {React.Ref} ref - A ref encaminhada para o TextInput.
|
|
7
|
+
*/
|
|
8
|
+
declare const Input: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
|
|
14
9
|
import React from 'react';
|
|
15
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Input/index.jsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Input/index.jsx"],"names":[],"mappings":";AAMA;;;;;GAKG;AACH,+EAyJG;kBArK0C,OAAO"}
|
|
@@ -1,74 +1,63 @@
|
|
|
1
1
|
import React, { useCallback, useState } from 'react';
|
|
2
|
-
import { View,
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import { View, TextInput, StyleSheet } from 'react-native';
|
|
3
|
+
import SEIcon from '~/superApp/UI/SEIcon';
|
|
4
|
+
import TooltipCard from '../TooltipCard';
|
|
5
|
+
import SEText from '../SEText';
|
|
6
|
+
/**
|
|
7
|
+
* Componente de Input controlado e reutilizável com suporte a máscaras e estados de validação.
|
|
8
|
+
* Usa React.forwardRef para permitir que o componente pai acesse o TextInput interno.
|
|
9
|
+
* @param {object} props - As propriedades do componente.
|
|
10
|
+
* @param {React.Ref} ref - A ref encaminhada para o TextInput.
|
|
11
|
+
*/
|
|
12
|
+
const Input = React.forwardRef(({ label, placeholder, value, onChangeText, error, success, disabled, supportText, mask, maskType, tooltipProps, // <-- Adicione esta prop para receber o tooltip
|
|
13
|
+
...textInputProps }, ref) => {
|
|
5
14
|
const [isFocused, setIsFocused] = useState(false);
|
|
6
|
-
const [isFilled, setIsFilled] = useState(false);
|
|
7
|
-
const [inputValue, setInputValue] = useState(value || '');
|
|
8
15
|
const handleChangeText = (text) => {
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
maskedText = applyMask(text, maskType);
|
|
12
|
-
}
|
|
13
|
-
setInputValue(maskedText);
|
|
14
|
-
setIsFilled(maskedText.length > 0);
|
|
15
|
-
if (onChangeText)
|
|
16
|
+
const maskedText = applyMask(text, maskType);
|
|
17
|
+
if (onChangeText) {
|
|
16
18
|
onChangeText(maskedText);
|
|
19
|
+
}
|
|
17
20
|
};
|
|
18
21
|
const applyMask = useCallback((text, type) => {
|
|
19
|
-
if (!
|
|
20
|
-
return
|
|
22
|
+
if (!mask || !type || !text)
|
|
23
|
+
return text;
|
|
21
24
|
const numbers = text.replace(/\D/g, '');
|
|
22
|
-
switch (type) {
|
|
25
|
+
switch (type.toLowerCase()) {
|
|
23
26
|
case 'cpf':
|
|
24
|
-
return
|
|
27
|
+
return numbers
|
|
28
|
+
.replace(/(\d{3})(\d)/, '$1.$2')
|
|
29
|
+
.replace(/(\d{3})(\d)/, '$1.$2')
|
|
30
|
+
.replace(/(\d{3})(\d{1,2})/, '$1-$2')
|
|
31
|
+
.slice(0, 14);
|
|
32
|
+
case 'cnpj':
|
|
33
|
+
return numbers
|
|
34
|
+
.replace(/(\d{2})(\d)/, '$1.$2')
|
|
35
|
+
.replace(/(\d{3})(\d)/, '$1.$2')
|
|
36
|
+
.replace(/(\d{3})(\d)/, '$1/$2')
|
|
37
|
+
.replace(/(\d{4})(\d{1,2})/, '$1-$2')
|
|
38
|
+
.replace(/(-\d{2})\d+?$/, '$1');
|
|
25
39
|
case 'cep':
|
|
26
|
-
return
|
|
40
|
+
return numbers.replace(/(\d{5})(\d)/, '$1-$2').slice(0, 9);
|
|
27
41
|
case 'phone':
|
|
28
|
-
|
|
42
|
+
if (numbers.length <= 10) {
|
|
43
|
+
return numbers
|
|
44
|
+
.replace(/(\d{2})(\d)/, '($1) $2')
|
|
45
|
+
.replace(/(\d{4})(\d)/, '$1-$2')
|
|
46
|
+
.slice(0, 14);
|
|
47
|
+
}
|
|
48
|
+
return numbers
|
|
49
|
+
.replace(/(\d{2})(\d)/, '($1) $2')
|
|
50
|
+
.replace(/(\d{5})(\d)/, '$1-$2')
|
|
51
|
+
.slice(0, 15);
|
|
29
52
|
case 'date':
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
53
|
+
return numbers
|
|
54
|
+
.replace(/(\d{2})(\d)/, '$1/$2')
|
|
55
|
+
.replace(/(\d{2})(\d)/, '$1/$2')
|
|
56
|
+
.slice(0, 10);
|
|
33
57
|
default:
|
|
34
58
|
return text;
|
|
35
59
|
}
|
|
36
60
|
}, [mask, maskType]);
|
|
37
|
-
const maskCPF = (value) => {
|
|
38
|
-
return value
|
|
39
|
-
.replace(/(\d{3})(\d)/, '$1.$2')
|
|
40
|
-
.replace(/(\d{3})(\d)/, '$1.$2')
|
|
41
|
-
.replace(/(\d{3})(\d{1,2})$/, '$1-$2');
|
|
42
|
-
};
|
|
43
|
-
const maskCEP = (value) => {
|
|
44
|
-
return value.replace(/(\d{5})(\d)/, '$1-$2');
|
|
45
|
-
};
|
|
46
|
-
const maskPhone = (value) => {
|
|
47
|
-
if (value.length <= 10) {
|
|
48
|
-
return value
|
|
49
|
-
.replace(/(\d{2})(\d)/, '($1) $2')
|
|
50
|
-
.replace(/(\d{4})(\d)/, '$1-$2');
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
return value
|
|
54
|
-
.replace(/(\d{2})(\d)/, '($1) $2')
|
|
55
|
-
.replace(/(\d{5})(\d)/, '$1-$2');
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const maskDate = (value) => {
|
|
59
|
-
return value
|
|
60
|
-
.replace(/(\d{2})(\d)/, '$1/$2')
|
|
61
|
-
.replace(/(\d{2})(\d)/, '$1/$2');
|
|
62
|
-
};
|
|
63
|
-
const maskCurrency = (value) => {
|
|
64
|
-
if (!value)
|
|
65
|
-
return '';
|
|
66
|
-
const numericValue = parseInt(value, 10) / 100;
|
|
67
|
-
return numericValue.toLocaleString('pt-BR', {
|
|
68
|
-
style: 'currency',
|
|
69
|
-
currency: 'BRL',
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
61
|
const getKeyboardType = () => {
|
|
73
62
|
if (!mask || !maskType)
|
|
74
63
|
return 'default';
|
|
@@ -87,16 +76,11 @@ const Input = ({ label, placeholder, value, onChangeText, error, success, disabl
|
|
|
87
76
|
if (!mask || !maskType)
|
|
88
77
|
return undefined;
|
|
89
78
|
switch (maskType) {
|
|
90
|
-
case 'cpf':
|
|
91
|
-
|
|
92
|
-
case '
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return 15;
|
|
96
|
-
case 'date':
|
|
97
|
-
return 10;
|
|
98
|
-
default:
|
|
99
|
-
return undefined;
|
|
79
|
+
case 'cpf': return 14;
|
|
80
|
+
case 'cep': return 9;
|
|
81
|
+
case 'phone': return 15;
|
|
82
|
+
case 'date': return 10;
|
|
83
|
+
default: return undefined;
|
|
100
84
|
}
|
|
101
85
|
};
|
|
102
86
|
const getContainerStyle = () => {
|
|
@@ -110,14 +94,14 @@ const Input = ({ label, placeholder, value, onChangeText, error, success, disabl
|
|
|
110
94
|
return styles.containerFocused;
|
|
111
95
|
return styles.container;
|
|
112
96
|
};
|
|
113
|
-
const
|
|
97
|
+
const getLabelColor = () => {
|
|
114
98
|
if (disabled)
|
|
115
|
-
return
|
|
99
|
+
return '#BFBFBF';
|
|
116
100
|
if (error)
|
|
117
|
-
return
|
|
101
|
+
return '#FF4D4F';
|
|
118
102
|
if (success)
|
|
119
|
-
return
|
|
120
|
-
return
|
|
103
|
+
return '#52C41A';
|
|
104
|
+
return '#333333';
|
|
121
105
|
};
|
|
122
106
|
const getInputStyle = () => {
|
|
123
107
|
if (disabled)
|
|
@@ -128,24 +112,24 @@ const Input = ({ label, placeholder, value, onChangeText, error, success, disabl
|
|
|
128
112
|
return styles.inputSuccess;
|
|
129
113
|
return styles.input;
|
|
130
114
|
};
|
|
131
|
-
const
|
|
115
|
+
const getSupportTextColor = () => {
|
|
132
116
|
if (error)
|
|
133
|
-
return
|
|
117
|
+
return '#FF4D4F';
|
|
134
118
|
if (success)
|
|
135
|
-
return
|
|
136
|
-
return
|
|
119
|
+
return '#52C41A';
|
|
120
|
+
return '#4F7CFE';
|
|
137
121
|
};
|
|
138
122
|
return (<View style={styles.wrapper}>
|
|
139
|
-
<
|
|
123
|
+
{label && <SEText type="ns-sm-body" color={getLabelColor()}>{label}</SEText>}
|
|
140
124
|
<View style={getContainerStyle()}>
|
|
141
|
-
<TextInput style={getInputStyle()} placeholder={placeholder} value={
|
|
142
|
-
{!disabled && <
|
|
143
|
-
{error && <
|
|
144
|
-
{success && <
|
|
125
|
+
<TextInput ref={ref} style={getInputStyle()} placeholder={placeholder} value={value} onChangeText={handleChangeText} onFocus={() => setIsFocused(true)} onBlur={() => setIsFocused(false)} editable={!disabled} keyboardType={getKeyboardType()} maxLength={getMaxLength()} placeholderTextColor="#BFBFBF" {...textInputProps}/>
|
|
126
|
+
{!disabled && tooltipProps ? (<TooltipCard {...tooltipProps} trigger={<SEIcon name="information-line" size={20} color="#687499"/>}/>) : !disabled && (<SEIcon name="information-line" size={20} color="#687499"/>)}
|
|
127
|
+
{error && <SEIcon name="close-line" size={20} color="#FF4D4F"/>}
|
|
128
|
+
{success && <SEIcon name="check-line" size={20} color="#52C41A"/>}
|
|
145
129
|
</View>
|
|
146
|
-
{supportText && <
|
|
130
|
+
{supportText && <SEText type="ns-xs-body" color={getSupportTextColor()}>{supportText}</SEText>}
|
|
147
131
|
</View>);
|
|
148
|
-
};
|
|
132
|
+
});
|
|
149
133
|
const styles = StyleSheet.create({
|
|
150
134
|
wrapper: {
|
|
151
135
|
width: '100%',
|
|
@@ -154,10 +138,9 @@ const styles = StyleSheet.create({
|
|
|
154
138
|
container: {
|
|
155
139
|
flexDirection: 'row',
|
|
156
140
|
alignItems: 'center',
|
|
157
|
-
borderWidth:
|
|
158
|
-
borderColor: '#
|
|
141
|
+
borderWidth: 2,
|
|
142
|
+
borderColor: '#96ACFF',
|
|
159
143
|
borderRadius: 8,
|
|
160
|
-
backgroundColor: '#F5F8FF',
|
|
161
144
|
paddingHorizontal: 12,
|
|
162
145
|
},
|
|
163
146
|
containerFocused: {
|
|
@@ -166,56 +149,32 @@ const styles = StyleSheet.create({
|
|
|
166
149
|
borderWidth: 2,
|
|
167
150
|
borderColor: '#4F7CFE',
|
|
168
151
|
borderRadius: 8,
|
|
169
|
-
backgroundColor: '#F5F8FF',
|
|
170
152
|
paddingHorizontal: 11,
|
|
171
153
|
},
|
|
172
154
|
containerError: {
|
|
173
155
|
flexDirection: 'row',
|
|
174
156
|
alignItems: 'center',
|
|
175
|
-
borderWidth:
|
|
157
|
+
borderWidth: 2,
|
|
176
158
|
borderColor: '#FF4D4F',
|
|
177
159
|
borderRadius: 8,
|
|
178
|
-
backgroundColor: '#FFF1F0',
|
|
179
160
|
paddingHorizontal: 12,
|
|
180
161
|
},
|
|
181
162
|
containerSuccess: {
|
|
182
163
|
flexDirection: 'row',
|
|
183
164
|
alignItems: 'center',
|
|
184
|
-
borderWidth:
|
|
165
|
+
borderWidth: 2,
|
|
185
166
|
borderColor: '#52C41A',
|
|
186
167
|
borderRadius: 8,
|
|
187
|
-
backgroundColor: '#F6FFED',
|
|
188
168
|
paddingHorizontal: 12,
|
|
189
169
|
},
|
|
190
170
|
containerDisabled: {
|
|
191
171
|
flexDirection: 'row',
|
|
192
172
|
alignItems: 'center',
|
|
193
|
-
borderWidth:
|
|
173
|
+
borderWidth: 2,
|
|
194
174
|
borderColor: '#E6EEFF',
|
|
195
175
|
borderRadius: 8,
|
|
196
|
-
backgroundColor: '#F5F5F5',
|
|
197
176
|
paddingHorizontal: 12,
|
|
198
177
|
},
|
|
199
|
-
label: {
|
|
200
|
-
fontSize: 14,
|
|
201
|
-
color: '#333333',
|
|
202
|
-
fontFamily: 'Nunito Sans',
|
|
203
|
-
},
|
|
204
|
-
labelError: {
|
|
205
|
-
fontSize: 14,
|
|
206
|
-
color: '#FF4D4F',
|
|
207
|
-
fontFamily: 'Nunito Sans',
|
|
208
|
-
},
|
|
209
|
-
labelSuccess: {
|
|
210
|
-
fontSize: 14,
|
|
211
|
-
color: '#52C41A',
|
|
212
|
-
fontFamily: 'Nunito Sans',
|
|
213
|
-
},
|
|
214
|
-
labelDisabled: {
|
|
215
|
-
fontSize: 14,
|
|
216
|
-
color: '#BFBFBF',
|
|
217
|
-
fontFamily: 'Nunito Sans',
|
|
218
|
-
},
|
|
219
178
|
input: {
|
|
220
179
|
flex: 1,
|
|
221
180
|
height: 40,
|
|
@@ -244,20 +203,5 @@ const styles = StyleSheet.create({
|
|
|
244
203
|
fontSize: 14,
|
|
245
204
|
fontFamily: 'Nunito Sans',
|
|
246
205
|
},
|
|
247
|
-
supportText: {
|
|
248
|
-
fontSize: 12,
|
|
249
|
-
color: '#4F7CFE',
|
|
250
|
-
fontFamily: 'Nunito Sans',
|
|
251
|
-
},
|
|
252
|
-
supportTextError: {
|
|
253
|
-
fontSize: 12,
|
|
254
|
-
color: '#FF4D4F',
|
|
255
|
-
fontFamily: 'Nunito Sans',
|
|
256
|
-
},
|
|
257
|
-
supportTextSuccess: {
|
|
258
|
-
fontSize: 12,
|
|
259
|
-
color: '#52C41A',
|
|
260
|
-
fontFamily: 'Nunito Sans',
|
|
261
|
-
},
|
|
262
206
|
});
|
|
263
207
|
export default Input;
|