vpt-sebraeds 0.0.28 → 0.0.29
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.
|
@@ -169,6 +169,15 @@ const Dropdown = ({
|
|
|
169
169
|
confirmButtonLabel,
|
|
170
170
|
onConfirm,
|
|
171
171
|
}) => {
|
|
172
|
+
// Estado centralizado para checkboxes
|
|
173
|
+
const [checkedItems, setCheckedItems] = useState({});
|
|
174
|
+
|
|
175
|
+
// Resetar estado quando o modal abre
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
if (isOpen) {
|
|
178
|
+
setCheckedItems({});
|
|
179
|
+
}
|
|
180
|
+
}, [isOpen]);
|
|
172
181
|
|
|
173
182
|
const handleSelect = (option) => {
|
|
174
183
|
if (onSelect) onSelect(option);
|
|
@@ -245,12 +254,20 @@ const Dropdown = ({
|
|
|
245
254
|
};
|
|
246
255
|
|
|
247
256
|
const RenderItem = ({ item, index }) => {
|
|
248
|
-
|
|
257
|
+
// Usar estado centralizado em vez de estado local
|
|
258
|
+
const isChecked = checkedItems[item.value] || false;
|
|
259
|
+
|
|
260
|
+
const handleCheckboxChange = () => {
|
|
261
|
+
setCheckedItems(prev => ({
|
|
262
|
+
...prev,
|
|
263
|
+
[item.value]: !prev[item.value]
|
|
264
|
+
}));
|
|
265
|
+
};
|
|
249
266
|
|
|
250
267
|
return item.isCheckbox ? (
|
|
251
268
|
<Checkbox
|
|
252
269
|
checked={isChecked}
|
|
253
|
-
onChange={
|
|
270
|
+
onChange={handleCheckboxChange}
|
|
254
271
|
label={item.label || item}
|
|
255
272
|
variant="check-line"
|
|
256
273
|
/>
|
|
@@ -309,7 +326,13 @@ const Dropdown = ({
|
|
|
309
326
|
<Button
|
|
310
327
|
label={confirmButtonLabel || "Confirmar"}
|
|
311
328
|
onPress={() => {
|
|
312
|
-
|
|
329
|
+
// Coletar itens selecionados
|
|
330
|
+
const selectedItems = options.filter(opt => checkedItems[opt.value]);
|
|
331
|
+
|
|
332
|
+
// Enviar para o componente pai
|
|
333
|
+
if (onSelect) onSelect(selectedItems);
|
|
334
|
+
if (onConfirm) onConfirm(selectedItems);
|
|
335
|
+
|
|
313
336
|
setIsOpen(false);
|
|
314
337
|
}}
|
|
315
338
|
size="large"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Dropdown/index.jsx"],"names":[],"mappings":"AA+FO,yDA6DN;;kBA3JkD,OAAO;AA+J1D;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Dropdown/index.jsx"],"names":[],"mappings":"AA+FO,yDA6DN;;kBA3JkD,OAAO;AA+J1D;;;;;;;;;;sBA4LC"}
|
|
@@ -136,6 +136,14 @@ export const DropdownCommitments = () => {
|
|
|
136
136
|
};
|
|
137
137
|
const { height: screenHeight } = Dimensions.get('window');
|
|
138
138
|
const Dropdown = ({ title, onSelect, options = [], withSeparator = false, isOpen = false, isCheckbox = false, setIsOpen = () => { }, confirmButtonLabel, onConfirm, }) => {
|
|
139
|
+
// Estado centralizado para checkboxes
|
|
140
|
+
const [checkedItems, setCheckedItems] = useState({});
|
|
141
|
+
// Resetar estado quando o modal abre
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (isOpen) {
|
|
144
|
+
setCheckedItems({});
|
|
145
|
+
}
|
|
146
|
+
}, [isOpen]);
|
|
139
147
|
const handleSelect = (option) => {
|
|
140
148
|
if (onSelect)
|
|
141
149
|
onSelect(option);
|
|
@@ -195,8 +203,15 @@ const Dropdown = ({ title, onSelect, options = [], withSeparator = false, isOpen
|
|
|
195
203
|
</TouchableWithoutFeedback>);
|
|
196
204
|
};
|
|
197
205
|
const RenderItem = ({ item, index }) => {
|
|
198
|
-
|
|
199
|
-
|
|
206
|
+
// Usar estado centralizado em vez de estado local
|
|
207
|
+
const isChecked = checkedItems[item.value] || false;
|
|
208
|
+
const handleCheckboxChange = () => {
|
|
209
|
+
setCheckedItems(prev => ({
|
|
210
|
+
...prev,
|
|
211
|
+
[item.value]: !prev[item.value]
|
|
212
|
+
}));
|
|
213
|
+
};
|
|
214
|
+
return item.isCheckbox ? (<Checkbox checked={isChecked} onChange={handleCheckboxChange} label={item.label || item} variant="check-line"/>) : (<RippleItem item={item} index={index} onPress={handleSelect}/>);
|
|
200
215
|
};
|
|
201
216
|
const hasCheckboxes = options.some(item => item.isCheckbox);
|
|
202
217
|
return (<View style={styles.wrapper}>
|
|
@@ -220,8 +235,13 @@ const Dropdown = ({ title, onSelect, options = [], withSeparator = false, isOpen
|
|
|
220
235
|
|
|
221
236
|
{hasCheckboxes && (<View style={styles.buttonContainer}>
|
|
222
237
|
<Button label={confirmButtonLabel || "Confirmar"} onPress={() => {
|
|
238
|
+
// Coletar itens selecionados
|
|
239
|
+
const selectedItems = options.filter(opt => checkedItems[opt.value]);
|
|
240
|
+
// Enviar para o componente pai
|
|
241
|
+
if (onSelect)
|
|
242
|
+
onSelect(selectedItems);
|
|
223
243
|
if (onConfirm)
|
|
224
|
-
onConfirm();
|
|
244
|
+
onConfirm(selectedItems);
|
|
225
245
|
setIsOpen(false);
|
|
226
246
|
}} size="large" variant="filled" expand/>
|
|
227
247
|
</View>)}
|