vpt-sebraeds 0.0.21 → 0.0.22
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/Checkbox/index.jsx +12 -8
- package/components/FilterTag/index.jsx +4 -7
- package/components/Link/index.jsx +9 -5
- package/components/ProgressChart/index.jsx +18 -13
- package/components/Select/index.jsx +69 -59
- package/components/Table/index.jsx +254 -125
- package/components/TaskCard/index.jsx +71 -55
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.js +5 -3
- package/dist/components/FilterTag/index.d.ts.map +1 -1
- package/dist/components/FilterTag/index.js +4 -6
- package/dist/components/Link/index.d.ts.map +1 -1
- package/dist/components/Link/index.js +6 -5
- package/dist/components/ProgressChart/index.d.ts.map +1 -1
- package/dist/components/ProgressChart/index.js +9 -12
- package/dist/components/Select/index.d.ts +4 -1
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +35 -38
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js +194 -94
- package/dist/components/TaskCard/index.d.ts +12 -1
- package/dist/components/TaskCard/index.d.ts.map +1 -1
- package/dist/components/TaskCard/index.js +53 -41
- package/package.json +1 -1
|
@@ -1,11 +1,83 @@
|
|
|
1
|
-
import React, { useState, useMemo,
|
|
2
|
-
import { View,
|
|
1
|
+
import React, { useState, useEffect, useMemo, useCallback, memo } from 'react';
|
|
2
|
+
import { View, StyleSheet, TouchableOpacity } from 'react-native';
|
|
3
|
+
import moment from 'moment';
|
|
3
4
|
import Icon from '../Icon';
|
|
4
5
|
import Select from '../Select';
|
|
6
|
+
import { SEText } from 'vpt-sebraeds';
|
|
5
7
|
const Table = ({ data = [], showMoreComponent, showFilters = false, onFilterChange, selectedRowIndex = null, onRowPress }) => {
|
|
6
|
-
const [selectedYear, setSelectedYear] = useState(
|
|
7
|
-
const [
|
|
8
|
-
const
|
|
8
|
+
const [selectedYear, setSelectedYear] = useState(null);
|
|
9
|
+
const [selectedStatuses, setSelectedStatuses] = useState([]);
|
|
10
|
+
const [selectedFilter, setSelectedFilter] = useState({});
|
|
11
|
+
// Inicializar filtros baseado nos dados
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (data && data.length > 0 && selectedYear === null) {
|
|
14
|
+
const firstDate = data[0].dtCompetenciaLocal;
|
|
15
|
+
const date = moment(firstDate, "YYYY-MM-DDTHH:mm:ss.SSSZ");
|
|
16
|
+
const initialYear = date.isValid() ? date.year() : moment().year();
|
|
17
|
+
setSelectedYear(initialYear);
|
|
18
|
+
setSelectedStatuses(['PAGO', 'A VENCER', 'ATRASADO']); // Todos os status inicialmente
|
|
19
|
+
}
|
|
20
|
+
}, [data]);
|
|
21
|
+
// Função para extrair o mês da data de competência local
|
|
22
|
+
const getMonthFromCompetenciaLocal = useCallback((dtCompetenciaLocal) => {
|
|
23
|
+
if (!dtCompetenciaLocal)
|
|
24
|
+
return "N/A";
|
|
25
|
+
const monthNames = [
|
|
26
|
+
'Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho',
|
|
27
|
+
'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'
|
|
28
|
+
];
|
|
29
|
+
const date = moment(dtCompetenciaLocal, "YYYY-MM-DDTHH:mm:ss.SSSZ");
|
|
30
|
+
if (!date.isValid())
|
|
31
|
+
return "N/A";
|
|
32
|
+
return monthNames[date.month()];
|
|
33
|
+
}, []);
|
|
34
|
+
// Função para extrair o ano da data de competência local
|
|
35
|
+
const getYearFromCompetenciaLocal = (dtCompetenciaLocal) => {
|
|
36
|
+
if (!dtCompetenciaLocal)
|
|
37
|
+
return null;
|
|
38
|
+
const date = moment(dtCompetenciaLocal, "YYYY-MM-DDTHH:mm:ss.SSSZ");
|
|
39
|
+
return date.isValid() ? date.year() : null;
|
|
40
|
+
};
|
|
41
|
+
// Função para mapear o status do backend para o status do componente
|
|
42
|
+
const mapStatus = (statusObj) => {
|
|
43
|
+
if (!statusObj)
|
|
44
|
+
return 'overdue';
|
|
45
|
+
switch (statusObj.label) {
|
|
46
|
+
case 'PAGO':
|
|
47
|
+
return 'paid';
|
|
48
|
+
case 'ATRASADO':
|
|
49
|
+
return 'late';
|
|
50
|
+
case 'A VENCER':
|
|
51
|
+
default:
|
|
52
|
+
return 'overdue';
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
// Função para formatar o valor
|
|
56
|
+
const formatPrice = (valorTotal) => {
|
|
57
|
+
if (!valorTotal || valorTotal === '0')
|
|
58
|
+
return 'R$ 0,00';
|
|
59
|
+
if (typeof valorTotal === 'string' && valorTotal.includes('R$')) {
|
|
60
|
+
return valorTotal;
|
|
61
|
+
}
|
|
62
|
+
const numValue = parseFloat(valorTotal);
|
|
63
|
+
return new Intl.NumberFormat('pt-BR', {
|
|
64
|
+
style: 'currency',
|
|
65
|
+
currency: 'BRL'
|
|
66
|
+
}).format(numValue);
|
|
67
|
+
};
|
|
68
|
+
const getStatusTextColor = (status) => {
|
|
69
|
+
switch (status) {
|
|
70
|
+
case 'paid':
|
|
71
|
+
return '#22C55E';
|
|
72
|
+
case 'overdue':
|
|
73
|
+
return '#1B244B';
|
|
74
|
+
case 'late':
|
|
75
|
+
return '#EF4444';
|
|
76
|
+
default:
|
|
77
|
+
return '#6B7280';
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const getStatusIconColor = (status) => {
|
|
9
81
|
switch (status) {
|
|
10
82
|
case 'paid':
|
|
11
83
|
return '#22C55E';
|
|
@@ -13,8 +85,6 @@ const Table = ({ data = [], showMoreComponent, showFilters = false, onFilterChan
|
|
|
13
85
|
return '#F59E0B';
|
|
14
86
|
case 'late':
|
|
15
87
|
return '#EF4444';
|
|
16
|
-
case 'unavailable':
|
|
17
|
-
return '#687499';
|
|
18
88
|
default:
|
|
19
89
|
return '#6B7280';
|
|
20
90
|
}
|
|
@@ -27,22 +97,21 @@ const Table = ({ data = [], showMoreComponent, showFilters = false, onFilterChan
|
|
|
27
97
|
return 'time-line';
|
|
28
98
|
case 'late':
|
|
29
99
|
return 'alert-line';
|
|
30
|
-
case 'unavailable':
|
|
31
|
-
return 'information-line';
|
|
32
100
|
default:
|
|
33
101
|
return 'time-line';
|
|
34
102
|
}
|
|
35
103
|
};
|
|
36
|
-
const getStatusText = (
|
|
37
|
-
|
|
104
|
+
const getStatusText = (statusData) => {
|
|
105
|
+
if (statusData && statusData.label) {
|
|
106
|
+
return statusData.label;
|
|
107
|
+
}
|
|
108
|
+
switch (statusData) {
|
|
38
109
|
case 'paid':
|
|
39
110
|
return 'Pago';
|
|
40
111
|
case 'overdue':
|
|
41
112
|
return 'A vencer';
|
|
42
113
|
case 'late':
|
|
43
114
|
return 'Atrasado';
|
|
44
|
-
case 'unavailable':
|
|
45
|
-
return 'Indisponível';
|
|
46
115
|
default:
|
|
47
116
|
return 'A vencer';
|
|
48
117
|
}
|
|
@@ -57,101 +126,123 @@ const Table = ({ data = [], showMoreComponent, showFilters = false, onFilterChan
|
|
|
57
126
|
if (isSelected) {
|
|
58
127
|
return styles.textSelected;
|
|
59
128
|
}
|
|
60
|
-
if (status === 'paid'
|
|
129
|
+
if (status === 'paid') {
|
|
61
130
|
return styles.textPaid;
|
|
62
131
|
}
|
|
63
|
-
|
|
64
|
-
return styles.textUnavailable;
|
|
65
|
-
}
|
|
66
|
-
return {};
|
|
132
|
+
return { fontWeight: '500' };
|
|
67
133
|
};
|
|
134
|
+
// Transformar dados do backend para o formato do componente
|
|
135
|
+
const transformedData = useMemo(() => {
|
|
136
|
+
return data
|
|
137
|
+
.map(item => ({
|
|
138
|
+
month: getMonthFromCompetenciaLocal(item.dtCompetenciaLocal),
|
|
139
|
+
price: formatPrice(item.valorTotal),
|
|
140
|
+
status: mapStatus(item.status),
|
|
141
|
+
statusData: item.status,
|
|
142
|
+
year: getYearFromCompetenciaLocal(item.dtCompetenciaLocal),
|
|
143
|
+
originalData: item
|
|
144
|
+
}))
|
|
145
|
+
.sort((a, b) => {
|
|
146
|
+
if (a.year !== b.year) {
|
|
147
|
+
return b.year - a.year;
|
|
148
|
+
}
|
|
149
|
+
const aMonth = new Date(a.originalData.dtCompetenciaLocal).getMonth();
|
|
150
|
+
const bMonth = new Date(b.originalData.dtCompetenciaLocal).getMonth();
|
|
151
|
+
return aMonth - bMonth;
|
|
152
|
+
});
|
|
153
|
+
}, [data]);
|
|
68
154
|
// Gerar opções de filtro dinamicamente
|
|
69
155
|
const yearOptions = useMemo(() => {
|
|
70
|
-
const years = [
|
|
71
|
-
return years.map(year => ({
|
|
156
|
+
const years = [...new Set(transformedData.map(item => item.year).filter(Boolean))];
|
|
157
|
+
return years.sort((a, b) => b - a).map(year => ({
|
|
72
158
|
value: year,
|
|
73
|
-
label: year
|
|
159
|
+
label: year.toString()
|
|
74
160
|
}));
|
|
75
|
-
}, [
|
|
161
|
+
}, [transformedData]);
|
|
76
162
|
const statusOptions = useMemo(() => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
value:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
163
|
+
return [
|
|
164
|
+
{ value: 'ATRASADO', label: 'Atrasado', isCheckbox: true },
|
|
165
|
+
{ value: 'A VENCER', label: 'A vencer', isCheckbox: true },
|
|
166
|
+
{ value: 'PAGO', label: 'Pago', isCheckbox: true },
|
|
167
|
+
{ value: 'INDISPONÍVEL', label: 'Indisponível', isCheckbox: true }
|
|
168
|
+
];
|
|
169
|
+
}, []);
|
|
170
|
+
// Handlers para os filtros
|
|
171
|
+
const handleYearChange = (yearOption) => {
|
|
172
|
+
const newYear = yearOption?.value || null;
|
|
173
|
+
setSelectedYear(newYear);
|
|
174
|
+
};
|
|
175
|
+
const handleStatusChange = (statusOption) => {
|
|
176
|
+
// Para o dropdown de status com checkboxes, vamos simular a seleção múltipla
|
|
177
|
+
// Por enquanto, vamos usar uma abordagem simplificada
|
|
178
|
+
setSelectedFilter({ year: selectedYear, statuses: statusOption?.map(option => option.value) ?? [] });
|
|
179
|
+
setSelectedStatuses(statusOption?.map(option => option.value) ?? []);
|
|
180
|
+
};
|
|
95
181
|
// Notificar mudanças de filtro
|
|
96
182
|
useEffect(() => {
|
|
97
183
|
if (onFilterChange) {
|
|
98
|
-
onFilterChange({ year: selectedYear,
|
|
184
|
+
onFilterChange({ year: selectedYear, statuses: selectedFilter.statuses });
|
|
99
185
|
}
|
|
100
|
-
}, [selectedYear,
|
|
186
|
+
}, [selectedYear, selectedStatuses, onFilterChange]);
|
|
101
187
|
return (<View style={styles.container}>
|
|
102
188
|
{showFilters && (<View style={styles.filtersContainer}>
|
|
103
|
-
<View style={styles.filterItem}>
|
|
104
|
-
<Select label="Ano" value={
|
|
189
|
+
<View style={[styles.filterItem, { width: '35%' }]}>
|
|
190
|
+
<Select label="Ano" value={yearOptions.find(option => option.value === selectedYear)} onSelect={handleYearChange} options={yearOptions} placeholder="Selecione o ano" displayMode="picker" innerTitle="Escolha um ano para exibir:" disabled={yearOptions.length === 0}/>
|
|
105
191
|
</View>
|
|
106
|
-
|
|
107
|
-
|
|
192
|
+
|
|
193
|
+
<View style={[styles.filterItem, { width: '60%' }]}>
|
|
194
|
+
<Select label="Status" value={statusOptions
|
|
195
|
+
.filter(option => selectedStatuses.includes(option.value))
|
|
196
|
+
.map(option => option.value)
|
|
197
|
+
.join(', ')
|
|
198
|
+
.toLowerCase()} onSelect={handleStatusChange} options={statusOptions} placeholder="Selecione o status" innerTitle="Escolha qual status exibir:"/>
|
|
108
199
|
</View>
|
|
109
200
|
</View>)}
|
|
110
|
-
|
|
111
|
-
{
|
|
201
|
+
|
|
202
|
+
{transformedData.length === 0 ? (<View style={styles.emptyContainer}>
|
|
203
|
+
<SEText type="ns-sm-body" style={styles.emptyText}>Nenhum registro encontrado</SEText>
|
|
204
|
+
</View>) : (transformedData.map((item, index) => {
|
|
112
205
|
const RowComponent = onRowPress ? TouchableOpacity : View;
|
|
113
206
|
const rowProps = onRowPress ? {
|
|
114
207
|
activeOpacity: 0.6,
|
|
115
208
|
onPress: () => onRowPress(index, item)
|
|
116
209
|
} : {};
|
|
117
210
|
const isSelected = selectedRowIndex === index;
|
|
118
|
-
return (<RowComponent key={index} style={getRowStyle(index)} {...rowProps}>
|
|
119
|
-
|
|
120
|
-
|
|
211
|
+
return (<RowComponent key={`${item.originalData.dtCompetenciaLocal}-${index}`} style={getRowStyle(index)} {...rowProps}>
|
|
212
|
+
<View style={styles.leftContent}>
|
|
213
|
+
<SEText type="ns-sm-body" style={[
|
|
121
214
|
styles.monthText,
|
|
122
|
-
getTextStyle(item.status, isSelected)
|
|
123
|
-
{ fontWeight: '500' }
|
|
215
|
+
getTextStyle(item.status, isSelected)
|
|
124
216
|
]}>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
217
|
+
{item.month}
|
|
218
|
+
</SEText>
|
|
219
|
+
</View>
|
|
220
|
+
|
|
221
|
+
<View style={styles.centerContent}>
|
|
222
|
+
<SEText type="ns-sm-body" style={[
|
|
131
223
|
styles.priceText,
|
|
132
|
-
getTextStyle(item.status, isSelected)
|
|
133
|
-
{ fontWeight: '500' }
|
|
224
|
+
getTextStyle(item.status, isSelected)
|
|
134
225
|
]}>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
226
|
+
{item.price}
|
|
227
|
+
</SEText>
|
|
228
|
+
</View>
|
|
229
|
+
|
|
230
|
+
<View style={styles.rightContent}>
|
|
231
|
+
<View style={styles.statusContainer}>
|
|
232
|
+
<SEText type="ns-sm-body" style={[
|
|
142
233
|
styles.statusText,
|
|
143
|
-
{ color:
|
|
144
|
-
getTextStyle(item.status)
|
|
234
|
+
{ color: getStatusTextColor(item.status) },
|
|
235
|
+
getTextStyle(item.status, isSelected)
|
|
145
236
|
]}>
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
237
|
+
{getStatusText(item.statusData)}
|
|
238
|
+
</SEText>
|
|
239
|
+
<Icon name={getStatusIcon(item.status)} size={16} color={getStatusIconColor(item.status)}/>
|
|
240
|
+
</View>
|
|
149
241
|
</View>
|
|
150
|
-
</
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
{showMoreComponent && (<View style={styles.showMoreContainer}>
|
|
242
|
+
</RowComponent>);
|
|
243
|
+
}))}
|
|
244
|
+
|
|
245
|
+
{showMoreComponent && transformedData.length !== 0 && (<View style={styles.showMoreContainer}>
|
|
155
246
|
{showMoreComponent}
|
|
156
247
|
</View>)}
|
|
157
248
|
</View>);
|
|
@@ -164,11 +255,13 @@ const styles = StyleSheet.create({
|
|
|
164
255
|
},
|
|
165
256
|
filtersContainer: {
|
|
166
257
|
flexDirection: 'row',
|
|
167
|
-
|
|
168
|
-
|
|
258
|
+
justifyContent: 'space-between',
|
|
259
|
+
marginBottom: 16,
|
|
260
|
+
paddingHorizontal: 0,
|
|
261
|
+
gap: 12,
|
|
169
262
|
},
|
|
170
263
|
filterItem: {
|
|
171
|
-
|
|
264
|
+
// flex: 1,
|
|
172
265
|
},
|
|
173
266
|
row: {
|
|
174
267
|
flexDirection: 'row',
|
|
@@ -186,8 +279,12 @@ const styles = StyleSheet.create({
|
|
|
186
279
|
rowSelected: {
|
|
187
280
|
backgroundColor: '#E3E9FF',
|
|
188
281
|
borderWidth: 2,
|
|
189
|
-
borderColor: '#3B82F6',
|
|
190
282
|
borderRadius: 8,
|
|
283
|
+
borderColor: '#3B82F6',
|
|
284
|
+
borderTopColor: '#3B82F6',
|
|
285
|
+
borderLeftColor: '#3B82F6',
|
|
286
|
+
borderRightColor: '#3B82F6',
|
|
287
|
+
borderBottomColor: '#3B82F6',
|
|
191
288
|
},
|
|
192
289
|
leftContent: {
|
|
193
290
|
flex: 1,
|
|
@@ -205,28 +302,18 @@ const styles = StyleSheet.create({
|
|
|
205
302
|
fontSize: 16,
|
|
206
303
|
fontWeight: '500',
|
|
207
304
|
color: '#1B244B',
|
|
208
|
-
fontFamily: 'Nunito Sans',
|
|
209
305
|
},
|
|
210
306
|
priceText: {
|
|
211
307
|
fontSize: 16,
|
|
212
308
|
fontWeight: '500',
|
|
213
309
|
color: '#1B244B',
|
|
214
|
-
fontFamily: 'Nunito Sans',
|
|
215
310
|
},
|
|
216
311
|
textSelected: {
|
|
217
|
-
color: '#1B244B',
|
|
218
312
|
fontWeight: '500',
|
|
219
|
-
fontFamily: 'Nunito Sans',
|
|
220
313
|
},
|
|
221
314
|
textPaid: {
|
|
222
315
|
color: '#1B244B',
|
|
223
|
-
fontWeight: '400', // Peso normal para itens "paid"
|
|
224
|
-
fontFamily: 'Nunito Sans',
|
|
225
|
-
},
|
|
226
|
-
textUnavailable: {
|
|
227
|
-
color: '#96A1C1', // Cor cinza azulada para itens indisponíveis
|
|
228
316
|
fontWeight: '400',
|
|
229
|
-
fontFamily: 'Nunito Sans',
|
|
230
317
|
},
|
|
231
318
|
statusContainer: {
|
|
232
319
|
flexDirection: 'row',
|
|
@@ -235,8 +322,21 @@ const styles = StyleSheet.create({
|
|
|
235
322
|
},
|
|
236
323
|
statusText: {
|
|
237
324
|
fontSize: 14,
|
|
238
|
-
|
|
239
|
-
|
|
325
|
+
marginRight: 4,
|
|
326
|
+
textTransform: 'capitalize',
|
|
327
|
+
},
|
|
328
|
+
emptyContainer: {
|
|
329
|
+
padding: 32,
|
|
330
|
+
alignItems: 'center',
|
|
331
|
+
justifyContent: 'center',
|
|
332
|
+
},
|
|
333
|
+
emptyText: {
|
|
334
|
+
fontSize: 16,
|
|
335
|
+
color: '#6B7280',
|
|
336
|
+
textAlign: 'center',
|
|
337
|
+
},
|
|
338
|
+
showMoreContainer: {
|
|
339
|
+
// Estilos para o container do ShowMore se necessário
|
|
240
340
|
},
|
|
241
341
|
});
|
|
242
342
|
export default Table;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export default TaskCard;
|
|
2
|
-
declare function TaskCard({ title, titleIcon, titleColor, children, middleContent, buttons, bottomContent, footerText, footerTextColor, onFooterPress, showMoreMenu, onMoreMenuPress, backgroundColor, borderRadius, padding, alignContentWithTitle, style, }: {
|
|
2
|
+
declare function TaskCard({ title, titleIcon, titleColor, subtitle, subtitleColor, children, middleContent, buttons, bottomContent, footerText, footerTextColor, onFooterPress, showMoreMenu, onMoreMenuPress, backgroundColor, backgroundColorIcon, borderRadius, padding, shadow, alignContentWithTitle, style, }: {
|
|
3
3
|
title: any;
|
|
4
4
|
titleIcon: any;
|
|
5
5
|
titleColor?: string | undefined;
|
|
6
|
+
subtitle: any;
|
|
7
|
+
subtitleColor?: string | undefined;
|
|
6
8
|
children: any;
|
|
7
9
|
middleContent: any;
|
|
8
10
|
buttons?: never[] | undefined;
|
|
@@ -13,8 +15,10 @@ declare function TaskCard({ title, titleIcon, titleColor, children, middleConten
|
|
|
13
15
|
showMoreMenu?: boolean | undefined;
|
|
14
16
|
onMoreMenuPress: any;
|
|
15
17
|
backgroundColor?: string | undefined;
|
|
18
|
+
backgroundColorIcon?: string | undefined;
|
|
16
19
|
borderRadius?: number | undefined;
|
|
17
20
|
padding?: number | undefined;
|
|
21
|
+
shadow?: boolean | undefined;
|
|
18
22
|
alignContentWithTitle?: boolean | undefined;
|
|
19
23
|
style: any;
|
|
20
24
|
}): React.JSX.Element;
|
|
@@ -23,6 +27,8 @@ declare namespace TaskCard {
|
|
|
23
27
|
let title: any;
|
|
24
28
|
let titleIcon: any;
|
|
25
29
|
let titleColor: any;
|
|
30
|
+
let subtitle: any;
|
|
31
|
+
let subtitleColor: any;
|
|
26
32
|
let children: any;
|
|
27
33
|
let middleContent: any;
|
|
28
34
|
let buttons: any;
|
|
@@ -35,12 +41,15 @@ declare namespace TaskCard {
|
|
|
35
41
|
let backgroundColor: any;
|
|
36
42
|
let borderRadius: any;
|
|
37
43
|
let padding: any;
|
|
44
|
+
let shadow: any;
|
|
38
45
|
let alignContentWithTitle: any;
|
|
39
46
|
let style: any;
|
|
40
47
|
}
|
|
41
48
|
namespace defaultProps {
|
|
42
49
|
let titleColor_1: string;
|
|
43
50
|
export { titleColor_1 as titleColor };
|
|
51
|
+
let subtitleColor_1: string;
|
|
52
|
+
export { subtitleColor_1 as subtitleColor };
|
|
44
53
|
let buttons_1: never[];
|
|
45
54
|
export { buttons_1 as buttons };
|
|
46
55
|
let footerText_1: string;
|
|
@@ -53,6 +62,8 @@ declare namespace TaskCard {
|
|
|
53
62
|
export { borderRadius_1 as borderRadius };
|
|
54
63
|
let padding_1: number;
|
|
55
64
|
export { padding_1 as padding };
|
|
65
|
+
let shadow_1: boolean;
|
|
66
|
+
export { shadow_1 as shadow };
|
|
56
67
|
let alignContentWithTitle_1: boolean;
|
|
57
68
|
export { alignContentWithTitle_1 as alignContentWithTitle };
|
|
58
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/TaskCard/index.jsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/TaskCard/index.jsx"],"names":[],"mappings":";AAOA;;;;;;;;;;;;;;;;;;;;;;sBAqKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA5KiB,OAAO"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View,
|
|
2
|
+
import { View, StyleSheet, TouchableOpacity } from 'react-native';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import Button from '../Button';
|
|
5
5
|
import Icon from '../Icon';
|
|
6
|
-
|
|
6
|
+
import SEText from '../SEText';
|
|
7
|
+
const TaskCard = ({ title, titleIcon, titleColor = '#1F1F1F', subtitle, subtitleColor = '#687499', children, middleContent, buttons = [], bottomContent, footerText = 'Lembrar mais tarde', footerTextColor = '#687499', onFooterPress, showMoreMenu = false, onMoreMenuPress, backgroundColor = '#FFFFFF', backgroundColorIcon = '#FFFFFF', borderRadius = 12, padding = 20, shadow = true, alignContentWithTitle = true, // Nova prop para controlar alinhamento
|
|
7
8
|
style, }) => {
|
|
8
9
|
const renderButtons = () => {
|
|
9
10
|
if (!buttons || buttons.length === 0)
|
|
@@ -17,7 +18,7 @@ style, }) => {
|
|
|
17
18
|
index > 0 && styles.buttonSpacing,
|
|
18
19
|
isDashedPrevious && styles.buttonSpacingAfterDashed
|
|
19
20
|
]}>
|
|
20
|
-
<Button label={button.label || 'Button'} size={button.size || 'medium'} variant={button.variant || 'filled'} disabled={button.disabled || false} onPress={button.onPress || (() => { })} iconName={button.iconName} iconPosition={button.iconPosition || 'both'} expand={true}
|
|
21
|
+
<Button label={button.label || 'Button'} size={button.size || 'medium'} variant={button.variant || 'filled'} disabled={button.disabled || false} onPress={button.onPress || (() => { })} iconName={button.iconName} iconPosition={button.iconPosition || 'both'} expand={true}/>
|
|
21
22
|
</View>);
|
|
22
23
|
})}
|
|
23
24
|
</View>);
|
|
@@ -25,20 +26,12 @@ style, }) => {
|
|
|
25
26
|
const renderFooter = () => {
|
|
26
27
|
if (!footerText)
|
|
27
28
|
return null;
|
|
28
|
-
return (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
styles.footerText,
|
|
35
|
-
{ color: footerTextColor }
|
|
36
|
-
]}>
|
|
37
|
-
{footerText}
|
|
38
|
-
</Text>
|
|
39
|
-
<Icon name="arrow-right-line" size={16} color={footerTextColor} style={styles.footerIcon}/>
|
|
40
|
-
</TouchableOpacity>
|
|
41
|
-
</>);
|
|
29
|
+
return (<TouchableOpacity style={styles.footerContainer} onPress={onFooterPress} activeOpacity={0.7}>
|
|
30
|
+
<SEText type="ns-sm-body" color={footerTextColor} style={styles.footerText}>
|
|
31
|
+
{footerText}
|
|
32
|
+
</SEText>
|
|
33
|
+
<Icon name="arrow-right-line" size={16} color={footerTextColor} style={styles.footerIcon}/>
|
|
34
|
+
</TouchableOpacity>);
|
|
42
35
|
};
|
|
43
36
|
return (<View style={[
|
|
44
37
|
styles.container,
|
|
@@ -47,18 +40,23 @@ style, }) => {
|
|
|
47
40
|
borderRadius,
|
|
48
41
|
padding,
|
|
49
42
|
},
|
|
50
|
-
styles.
|
|
43
|
+
shadow && styles.shadow,
|
|
51
44
|
style,
|
|
52
45
|
]}>
|
|
53
46
|
{/* Header com título */}
|
|
54
47
|
{title && (<View style={styles.header}>
|
|
55
48
|
<View style={styles.headerContent}>
|
|
56
|
-
{titleIcon && (<View style={styles.titleIconContainer}>
|
|
49
|
+
{titleIcon && (<View style={[styles.titleIconContainer, backgroundColorIcon && { backgroundColor: backgroundColorIcon }]}>
|
|
57
50
|
{titleIcon}
|
|
58
51
|
</View>)}
|
|
59
|
-
<
|
|
60
|
-
{title}
|
|
61
|
-
|
|
52
|
+
<View style={{ flex: 1 }}>
|
|
53
|
+
<SEText type="ns-sm-body-bold" color={titleColor} style={styles.title}>
|
|
54
|
+
{title}
|
|
55
|
+
</SEText>
|
|
56
|
+
{subtitle && (<SEText type="ns-sm-body" color={subtitleColor} style={styles.subtitle}>
|
|
57
|
+
{subtitle}
|
|
58
|
+
</SEText>)}
|
|
59
|
+
</View>
|
|
62
60
|
</View>
|
|
63
61
|
{showMoreMenu && (<TouchableOpacity style={styles.moreMenuButton} onPress={onMoreMenuPress} activeOpacity={0.7}>
|
|
64
62
|
<Icon name="more-2-fill" size={20} color="#666666"/>
|
|
@@ -95,6 +93,8 @@ TaskCard.propTypes = {
|
|
|
95
93
|
title: PropTypes.string,
|
|
96
94
|
titleIcon: PropTypes.element,
|
|
97
95
|
titleColor: PropTypes.string,
|
|
96
|
+
subtitle: PropTypes.string,
|
|
97
|
+
subtitleColor: PropTypes.string,
|
|
98
98
|
children: PropTypes.node,
|
|
99
99
|
middleContent: PropTypes.node,
|
|
100
100
|
buttons: PropTypes.arrayOf(PropTypes.shape({
|
|
@@ -115,26 +115,37 @@ TaskCard.propTypes = {
|
|
|
115
115
|
backgroundColor: PropTypes.string,
|
|
116
116
|
borderRadius: PropTypes.number,
|
|
117
117
|
padding: PropTypes.number,
|
|
118
|
+
shadow: PropTypes.bool,
|
|
118
119
|
alignContentWithTitle: PropTypes.bool,
|
|
119
120
|
style: PropTypes.object,
|
|
120
121
|
};
|
|
121
122
|
TaskCard.defaultProps = {
|
|
122
123
|
titleColor: '#1F1F1F',
|
|
124
|
+
subtitleColor: '#687499',
|
|
123
125
|
buttons: [],
|
|
124
126
|
footerText: 'Lembrar mais tarde',
|
|
125
127
|
footerTextColor: '#687499',
|
|
126
128
|
backgroundColor: '#FFFFFF',
|
|
127
129
|
borderRadius: 12,
|
|
128
130
|
padding: 20,
|
|
131
|
+
shadow: true,
|
|
129
132
|
alignContentWithTitle: true,
|
|
130
133
|
};
|
|
131
134
|
const styles = StyleSheet.create({
|
|
132
135
|
container: {
|
|
133
136
|
width: '100%',
|
|
134
|
-
},
|
|
135
|
-
border: {
|
|
136
137
|
borderWidth: 1.5,
|
|
137
|
-
borderColor: '#E2E9FC',
|
|
138
|
+
borderColor: '#E2E9FC',
|
|
139
|
+
},
|
|
140
|
+
shadow: {
|
|
141
|
+
// shadowColor: '#000',
|
|
142
|
+
// shadowOffset: {
|
|
143
|
+
// width: 0,
|
|
144
|
+
// height: 2,
|
|
145
|
+
// },
|
|
146
|
+
// shadowOpacity: 0.1,
|
|
147
|
+
// shadowRadius: 8,
|
|
148
|
+
// elevation: 2,
|
|
138
149
|
},
|
|
139
150
|
header: {
|
|
140
151
|
flexDirection: 'row',
|
|
@@ -144,7 +155,7 @@ const styles = StyleSheet.create({
|
|
|
144
155
|
},
|
|
145
156
|
headerContent: {
|
|
146
157
|
flexDirection: 'row',
|
|
147
|
-
alignItems: '
|
|
158
|
+
alignItems: 'flex-start',
|
|
148
159
|
flex: 1,
|
|
149
160
|
},
|
|
150
161
|
moreMenuButton: {
|
|
@@ -152,15 +163,22 @@ const styles = StyleSheet.create({
|
|
|
152
163
|
borderRadius: 4,
|
|
153
164
|
},
|
|
154
165
|
titleIconContainer: {
|
|
155
|
-
|
|
166
|
+
justifyContent: 'center',
|
|
167
|
+
alignItems: 'center',
|
|
168
|
+
borderRadius: 6,
|
|
169
|
+
position: 'relative',
|
|
170
|
+
width: 35,
|
|
171
|
+
height: 35,
|
|
172
|
+
marginRight: 16,
|
|
156
173
|
},
|
|
157
174
|
title: {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
175
|
+
fontSize: 16,
|
|
176
|
+
lineHeight: 24,
|
|
177
|
+
marginBottom: 4,
|
|
178
|
+
},
|
|
179
|
+
subtitle: {
|
|
180
|
+
fontSize: 14,
|
|
181
|
+
lineHeight: 20,
|
|
164
182
|
},
|
|
165
183
|
contentContainer: {
|
|
166
184
|
marginBottom: 16,
|
|
@@ -186,23 +204,17 @@ const styles = StyleSheet.create({
|
|
|
186
204
|
bottomContentContainer: {
|
|
187
205
|
marginBottom: 16,
|
|
188
206
|
},
|
|
189
|
-
footerDivider: {
|
|
190
|
-
height: 1,
|
|
191
|
-
backgroundColor: '#E2E9FC',
|
|
192
|
-
marginHorizontal: -20, // Compensa o padding do card para linha cheia
|
|
193
|
-
marginBottom: 16,
|
|
194
|
-
},
|
|
195
207
|
footerContainer: {
|
|
196
208
|
flexDirection: 'row',
|
|
197
209
|
alignItems: 'center',
|
|
198
210
|
justifyContent: 'center',
|
|
199
|
-
|
|
211
|
+
paddingVertical: 4,
|
|
200
212
|
},
|
|
201
213
|
footerText: {
|
|
202
214
|
fontSize: 14,
|
|
203
215
|
fontWeight: '400',
|
|
204
|
-
fontFamily: 'Nunito Sans',
|
|
205
216
|
textAlign: 'center',
|
|
217
|
+
textDecorationLine: 'underline',
|
|
206
218
|
},
|
|
207
219
|
footerIcon: {
|
|
208
220
|
marginLeft: 4,
|