vpt-sebraeds 0.0.29 → 0.0.31

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.
@@ -157,6 +157,7 @@ export const DropdownCommitments = () => {
157
157
  }
158
158
 
159
159
  const { height: screenHeight } = Dimensions.get('window');
160
+ const ITEM_HEIGHT = 50;
160
161
 
161
162
  const Dropdown = ({
162
163
  title,
@@ -168,19 +169,29 @@ const Dropdown = ({
168
169
  setIsOpen = () => { },
169
170
  confirmButtonLabel,
170
171
  onConfirm,
172
+ displayMode = 'list',
173
+ selectedValue,
171
174
  }) => {
172
175
  // Estado centralizado para checkboxes
173
176
  const [checkedItems, setCheckedItems] = useState({});
177
+ const scrollViewRef = useRef(null);
178
+ const [selectedIndex, setSelectedIndex] = useState(0);
174
179
 
175
180
  // Resetar estado quando o modal abre
176
181
  useEffect(() => {
177
182
  if (isOpen) {
178
183
  setCheckedItems({});
184
+ // Para modo picker, encontrar índice do item selecionado
185
+ if (displayMode === 'picker' && selectedValue) {
186
+ const idx = options.findIndex(opt => opt.value === selectedValue || opt === selectedValue);
187
+ setSelectedIndex(idx >= 0 ? idx : 0);
188
+ }
179
189
  }
180
- }, [isOpen]);
190
+ }, [isOpen, displayMode, selectedValue, options]);
181
191
 
182
192
  const handleSelect = (option) => {
183
193
  if (onSelect) onSelect(option);
194
+ setIsOpen(false); // Fechar modal após seleção
184
195
  };
185
196
 
186
197
  const RippleItem = ({ item, index, onPress }) => {
@@ -253,6 +264,31 @@ const Dropdown = ({
253
264
  );
254
265
  };
255
266
 
267
+ // Picker Item com estilos dinâmicos baseados na distância do centro
268
+ const PickerItem = ({ item, index }) => {
269
+ const distance = Math.abs(index - selectedIndex);
270
+ const isSelected = index === selectedIndex;
271
+
272
+ const getTextStyle = () => {
273
+ if (isSelected) return styles.pickerSelectedText;
274
+ if (distance === 1) return styles.pickerAdjacentText;
275
+ return styles.pickerDistantText;
276
+ };
277
+
278
+ return (
279
+ <TouchableOpacity
280
+ style={styles.pickerItem}
281
+ onPress={() => {
282
+ setSelectedIndex(index);
283
+ handleSelect(item);
284
+ }}
285
+ activeOpacity={0.7}
286
+ >
287
+ <Text style={[styles.pickerItemText, getTextStyle()]}>{item.label || item}</Text>
288
+ </TouchableOpacity>
289
+ );
290
+ };
291
+
256
292
  const RenderItem = ({ item, index }) => {
257
293
  // Usar estado centralizado em vez de estado local
258
294
  const isChecked = checkedItems[item.value] || false;
@@ -281,6 +317,47 @@ const Dropdown = ({
281
317
  };
282
318
 
283
319
  const hasCheckboxes = options.some(item => item.isCheckbox);
320
+ const isPicker = displayMode === 'picker';
321
+
322
+ // Renderizar conteúdo baseado no modo
323
+ const renderContent = () => {
324
+ if (isPicker) {
325
+ return (
326
+ <View style={styles.pickerContainer}>
327
+ <ScrollView
328
+ ref={scrollViewRef}
329
+ style={styles.pickerScrollView}
330
+ contentContainerStyle={{
331
+ paddingVertical: ITEM_HEIGHT * 2
332
+ }}
333
+ showsVerticalScrollIndicator={false}
334
+ snapToInterval={ITEM_HEIGHT}
335
+ decelerationRate="fast"
336
+ onMomentumScrollEnd={(e) => {
337
+ const idx = Math.round(e.nativeEvent.contentOffset.y / ITEM_HEIGHT);
338
+ const clampedIdx = Math.max(0, Math.min(idx, options.length - 1));
339
+ setSelectedIndex(clampedIdx);
340
+ }}
341
+ onLayout={() => {
342
+ if (scrollViewRef.current && selectedIndex >= 0) {
343
+ scrollViewRef.current.scrollTo({ y: selectedIndex * ITEM_HEIGHT, animated: false });
344
+ }
345
+ }}
346
+ >
347
+ {options.map((item, index) => (
348
+ <PickerItem key={index.toString()} item={item} index={index} />
349
+ ))}
350
+ </ScrollView>
351
+ </View>
352
+ );
353
+ }
354
+
355
+ return (
356
+ <ScrollView style={styles.optionsList} contentContainerStyle={{ paddingBottom: 8 }} showsVerticalScrollIndicator={false} bounces={false}>
357
+ {options.map((item, index) => (<RenderItem key={index.toString()} item={item} index={index} />))}
358
+ </ScrollView>
359
+ );
360
+ };
284
361
 
285
362
  return (
286
363
  <View style={styles.wrapper}>
@@ -301,38 +378,27 @@ const Dropdown = ({
301
378
  {/* Conteúdo do modal - não propaga toque para o overlay */}
302
379
  <View style={styles.modalContainer}>
303
380
  <View style={styles.modalHeader}>
304
- <TouchableOpacity
305
- onPress={() => setIsOpen(false)}
306
- style={styles.closeButton}
307
- >
308
- <Icon name="subtract-line" size={26} color="#687499" />
309
- </TouchableOpacity>
310
381
  <Text style={styles.modalTitle}>{title || "Título"}</Text>
311
382
  </View>
312
383
 
313
- <ScrollView
314
- style={styles.optionsList}
315
- contentContainerStyle={{ paddingBottom: 8 }}
316
- showsVerticalScrollIndicator={false}
317
- bounces={false}
318
- >
319
- {options.map((item, index) => (
320
- <RenderItem key={index.toString()} item={item} index={index} />
321
- ))}
322
- </ScrollView>
323
-
324
- {hasCheckboxes && (
384
+ {renderContent()}
385
+
386
+ {(hasCheckboxes || isPicker) && (
325
387
  <View style={styles.buttonContainer}>
326
388
  <Button
327
389
  label={confirmButtonLabel || "Confirmar"}
328
390
  onPress={() => {
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
-
391
+ if (isPicker) {
392
+ // Para picker, enviar o item selecionado pelo índice
393
+ const selectedItem = options[selectedIndex];
394
+ if (onSelect) onSelect(selectedItem);
395
+ if (onConfirm) onConfirm(selectedItem);
396
+ } else {
397
+ // Para checkboxes, coletar itens selecionados
398
+ const selectedItems = options.filter(opt => checkedItems[opt.value]);
399
+ if (onSelect) onSelect(selectedItems);
400
+ if (onConfirm) onConfirm(selectedItems);
401
+ }
336
402
  setIsOpen(false);
337
403
  }}
338
404
  size="large"
@@ -418,6 +484,38 @@ const styles = StyleSheet.create({
418
484
  paddingTop: 16,
419
485
  paddingBottom: 8,
420
486
  },
487
+ // Picker styles
488
+ pickerContainer: {
489
+ height: ITEM_HEIGHT * 5,
490
+ overflow: 'hidden',
491
+ },
492
+ pickerScrollView: {
493
+ flex: 1,
494
+ },
495
+ pickerItem: {
496
+ height: ITEM_HEIGHT,
497
+ justifyContent: 'center',
498
+ alignItems: 'center',
499
+ },
500
+ pickerItemText: {
501
+ fontFamily: 'Nunito Sans',
502
+ textAlign: 'center',
503
+ },
504
+ pickerSelectedText: {
505
+ fontSize: 24,
506
+ fontWeight: 'bold',
507
+ color: '#1B244B',
508
+ },
509
+ pickerAdjacentText: {
510
+ fontSize: 18,
511
+ fontWeight: '500',
512
+ color: '#687499',
513
+ },
514
+ pickerDistantText: {
515
+ fontSize: 14,
516
+ fontWeight: '400',
517
+ color: '#CED2DE',
518
+ },
421
519
  });
422
520
 
423
521
  export default Dropdown;
@@ -106,11 +106,11 @@ const NavigationItem: React.FC<NavigationItemProps> = ({
106
106
  const getArrowSize = () => {
107
107
  switch (size) {
108
108
  case 'small':
109
- return 11; // Proporcionalmente menor que 13.33
109
+ return 11;
110
110
  case 'large':
111
- return 16; // Proporcionalmente maior que 13.33
111
+ return 20;
112
112
  default:
113
- return 13.33; // Tamanho exato do Figma
113
+ return 20;
114
114
  }
115
115
  };
116
116
 
@@ -179,10 +179,10 @@ const NavigationItem: React.FC<NavigationItemProps> = ({
179
179
 
180
180
  {layout === 'expanded' && description ? (
181
181
  <View style={styles.textContainer}>
182
- <SEText
183
- type="ns-sm-body-semibold"
184
- color={variant === 'disabled' ? '#9CA3AF' : textColor || '#1B244B'}
185
- style={styles.labelExpanded}
182
+ <SEText
183
+ type="ns-sm-body-semibold"
184
+ color={variant === 'disabled' ? '#9CA3AF' : textColor || '#1B244B'}
185
+ style={styles.labelExpanded}
186
186
  numberOfLines={1}
187
187
  >
188
188
  {label}
@@ -199,10 +199,10 @@ const NavigationItem: React.FC<NavigationItemProps> = ({
199
199
  {label}
200
200
  </SEText>
201
201
  ) : (
202
- <SEText
203
- type="ns-sm-body-semibold"
204
- color={variant === 'disabled' ? '#9CA3AF' : variant === 'selected' ? '#1B244B' : textColor || '#1B244B'}
205
- style={labelStyle}
202
+ <SEText
203
+ type="ns-sm-body-semibold"
204
+ color={variant === 'disabled' ? '#9CA3AF' : variant === 'selected' ? '#1B244B' : textColor || '#1B244B'}
205
+ style={labelStyle}
206
206
  numberOfLines={1}
207
207
  >
208
208
  {label}
@@ -359,7 +359,7 @@ const styles = StyleSheet.create({
359
359
  width: 48,
360
360
  height: 48,
361
361
  borderRadius: 12,
362
- alignSelf: 'flex-start', // Alinha o ícone com o topo
362
+ alignSelf: 'center',
363
363
  },
364
364
  iconContainerHidden: {
365
365
  width: 0,
@@ -1,7 +1,7 @@
1
1
  export function DropdownCommitments(): React.JSX.Element;
2
2
  export default Dropdown;
3
3
  import React from 'react';
4
- declare function Dropdown({ title, onSelect, options, withSeparator, isOpen, isCheckbox, setIsOpen, confirmButtonLabel, onConfirm, }: {
4
+ declare function Dropdown({ title, onSelect, options, withSeparator, isOpen, isCheckbox, setIsOpen, confirmButtonLabel, onConfirm, displayMode, selectedValue, }: {
5
5
  title: any;
6
6
  onSelect: any;
7
7
  options?: never[] | undefined;
@@ -11,5 +11,7 @@ declare function Dropdown({ title, onSelect, options, withSeparator, isOpen, isC
11
11
  setIsOpen?: (() => void) | undefined;
12
12
  confirmButtonLabel: any;
13
13
  onConfirm: any;
14
+ displayMode?: string | undefined;
15
+ selectedValue: any;
14
16
  }): React.JSX.Element;
15
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Dropdown/index.jsx"],"names":[],"mappings":"AA+FO,yDA6DN;;kBA3JkD,OAAO;AA+J1D;;;;;;;;;;sBA4LC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/Dropdown/index.jsx"],"names":[],"mappings":"AA+FO,yDA6DN;;kBA3JkD,OAAO;AAgK1D;;;;;;;;;;;;sBA6PC"}
@@ -135,18 +135,27 @@ export const DropdownCommitments = () => {
135
135
  </View>);
136
136
  };
137
137
  const { height: screenHeight } = Dimensions.get('window');
138
- const Dropdown = ({ title, onSelect, options = [], withSeparator = false, isOpen = false, isCheckbox = false, setIsOpen = () => { }, confirmButtonLabel, onConfirm, }) => {
138
+ const ITEM_HEIGHT = 50;
139
+ const Dropdown = ({ title, onSelect, options = [], withSeparator = false, isOpen = false, isCheckbox = false, setIsOpen = () => { }, confirmButtonLabel, onConfirm, displayMode = 'list', selectedValue, }) => {
139
140
  // Estado centralizado para checkboxes
140
141
  const [checkedItems, setCheckedItems] = useState({});
142
+ const scrollViewRef = useRef(null);
143
+ const [selectedIndex, setSelectedIndex] = useState(0);
141
144
  // Resetar estado quando o modal abre
142
145
  useEffect(() => {
143
146
  if (isOpen) {
144
147
  setCheckedItems({});
148
+ // Para modo picker, encontrar índice do item selecionado
149
+ if (displayMode === 'picker' && selectedValue) {
150
+ const idx = options.findIndex(opt => opt.value === selectedValue || opt === selectedValue);
151
+ setSelectedIndex(idx >= 0 ? idx : 0);
152
+ }
145
153
  }
146
- }, [isOpen]);
154
+ }, [isOpen, displayMode, selectedValue, options]);
147
155
  const handleSelect = (option) => {
148
156
  if (onSelect)
149
157
  onSelect(option);
158
+ setIsOpen(false); // Fechar modal após seleção
150
159
  };
151
160
  const RippleItem = ({ item, index, onPress }) => {
152
161
  const [ripples, setRipples] = useState([]);
@@ -202,6 +211,24 @@ const Dropdown = ({ title, onSelect, options = [], withSeparator = false, isOpen
202
211
  </View>
203
212
  </TouchableWithoutFeedback>);
204
213
  };
214
+ // Picker Item com estilos dinâmicos baseados na distância do centro
215
+ const PickerItem = ({ item, index }) => {
216
+ const distance = Math.abs(index - selectedIndex);
217
+ const isSelected = index === selectedIndex;
218
+ const getTextStyle = () => {
219
+ if (isSelected)
220
+ return styles.pickerSelectedText;
221
+ if (distance === 1)
222
+ return styles.pickerAdjacentText;
223
+ return styles.pickerDistantText;
224
+ };
225
+ return (<TouchableOpacity style={styles.pickerItem} onPress={() => {
226
+ setSelectedIndex(index);
227
+ handleSelect(item);
228
+ }} activeOpacity={0.7}>
229
+ <Text style={[styles.pickerItemText, getTextStyle()]}>{item.label || item}</Text>
230
+ </TouchableOpacity>);
231
+ };
205
232
  const RenderItem = ({ item, index }) => {
206
233
  // Usar estado centralizado em vez de estado local
207
234
  const isChecked = checkedItems[item.value] || false;
@@ -214,6 +241,30 @@ const Dropdown = ({ title, onSelect, options = [], withSeparator = false, isOpen
214
241
  return item.isCheckbox ? (<Checkbox checked={isChecked} onChange={handleCheckboxChange} label={item.label || item} variant="check-line"/>) : (<RippleItem item={item} index={index} onPress={handleSelect}/>);
215
242
  };
216
243
  const hasCheckboxes = options.some(item => item.isCheckbox);
244
+ const isPicker = displayMode === 'picker';
245
+ // Renderizar conteúdo baseado no modo
246
+ const renderContent = () => {
247
+ if (isPicker) {
248
+ return (<View style={styles.pickerContainer}>
249
+ <ScrollView ref={scrollViewRef} style={styles.pickerScrollView} contentContainerStyle={{
250
+ paddingVertical: ITEM_HEIGHT * 2
251
+ }} showsVerticalScrollIndicator={false} snapToInterval={ITEM_HEIGHT} decelerationRate="fast" onMomentumScrollEnd={(e) => {
252
+ const idx = Math.round(e.nativeEvent.contentOffset.y / ITEM_HEIGHT);
253
+ const clampedIdx = Math.max(0, Math.min(idx, options.length - 1));
254
+ setSelectedIndex(clampedIdx);
255
+ }} onLayout={() => {
256
+ if (scrollViewRef.current && selectedIndex >= 0) {
257
+ scrollViewRef.current.scrollTo({ y: selectedIndex * ITEM_HEIGHT, animated: false });
258
+ }
259
+ }}>
260
+ {options.map((item, index) => (<PickerItem key={index.toString()} item={item} index={index}/>))}
261
+ </ScrollView>
262
+ </View>);
263
+ }
264
+ return (<ScrollView style={styles.optionsList} contentContainerStyle={{ paddingBottom: 8 }} showsVerticalScrollIndicator={false} bounces={false}>
265
+ {options.map((item, index) => (<RenderItem key={index.toString()} item={item} index={index}/>))}
266
+ </ScrollView>);
267
+ };
217
268
  return (<View style={styles.wrapper}>
218
269
  <Modal visible={isOpen} transparent={true} animationType="fade" onRequestClose={() => setIsOpen(false)}>
219
270
  <View style={styles.overlay}>
@@ -223,25 +274,29 @@ const Dropdown = ({ title, onSelect, options = [], withSeparator = false, isOpen
223
274
  {/* Conteúdo do modal - não propaga toque para o overlay */}
224
275
  <View style={styles.modalContainer}>
225
276
  <View style={styles.modalHeader}>
226
- <TouchableOpacity onPress={() => setIsOpen(false)} style={styles.closeButton}>
227
- <Icon name="subtract-line" size={26} color="#687499"/>
228
- </TouchableOpacity>
229
277
  <Text style={styles.modalTitle}>{title || "Título"}</Text>
230
278
  </View>
231
279
 
232
- <ScrollView style={styles.optionsList} contentContainerStyle={{ paddingBottom: 8 }} showsVerticalScrollIndicator={false} bounces={false}>
233
- {options.map((item, index) => (<RenderItem key={index.toString()} item={item} index={index}/>))}
234
- </ScrollView>
280
+ {renderContent()}
235
281
 
236
- {hasCheckboxes && (<View style={styles.buttonContainer}>
282
+ {(hasCheckboxes || isPicker) && (<View style={styles.buttonContainer}>
237
283
  <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);
243
- if (onConfirm)
244
- onConfirm(selectedItems);
284
+ if (isPicker) {
285
+ // Para picker, enviar o item selecionado pelo índice
286
+ const selectedItem = options[selectedIndex];
287
+ if (onSelect)
288
+ onSelect(selectedItem);
289
+ if (onConfirm)
290
+ onConfirm(selectedItem);
291
+ }
292
+ else {
293
+ // Para checkboxes, coletar itens selecionados
294
+ const selectedItems = options.filter(opt => checkedItems[opt.value]);
295
+ if (onSelect)
296
+ onSelect(selectedItems);
297
+ if (onConfirm)
298
+ onConfirm(selectedItems);
299
+ }
245
300
  setIsOpen(false);
246
301
  }} size="large" variant="filled" expand/>
247
302
  </View>)}
@@ -320,5 +375,37 @@ const styles = StyleSheet.create({
320
375
  paddingTop: 16,
321
376
  paddingBottom: 8,
322
377
  },
378
+ // Picker styles
379
+ pickerContainer: {
380
+ height: ITEM_HEIGHT * 5,
381
+ overflow: 'hidden',
382
+ },
383
+ pickerScrollView: {
384
+ flex: 1,
385
+ },
386
+ pickerItem: {
387
+ height: ITEM_HEIGHT,
388
+ justifyContent: 'center',
389
+ alignItems: 'center',
390
+ },
391
+ pickerItemText: {
392
+ fontFamily: 'Nunito Sans',
393
+ textAlign: 'center',
394
+ },
395
+ pickerSelectedText: {
396
+ fontSize: 24,
397
+ fontWeight: 'bold',
398
+ color: '#1B244B',
399
+ },
400
+ pickerAdjacentText: {
401
+ fontSize: 18,
402
+ fontWeight: '500',
403
+ color: '#687499',
404
+ },
405
+ pickerDistantText: {
406
+ fontSize: 14,
407
+ fontWeight: '400',
408
+ color: '#CED2DE',
409
+ },
323
410
  });
324
411
  export default Dropdown;
@@ -64,11 +64,11 @@ const NavigationItem = ({ iconName, label, variant = 'default', size = 'medium',
64
64
  const getArrowSize = () => {
65
65
  switch (size) {
66
66
  case 'small':
67
- return 11; // Proporcionalmente menor que 13.33
67
+ return 11;
68
68
  case 'large':
69
- return 16; // Proporcionalmente maior que 13.33
69
+ return 20;
70
70
  default:
71
- return 13.33; // Tamanho exato do Figma
71
+ return 20;
72
72
  }
73
73
  };
74
74
  const getBadgeStyle = () => {
@@ -260,7 +260,7 @@ const styles = StyleSheet.create({
260
260
  width: 48,
261
261
  height: 48,
262
262
  borderRadius: 12,
263
- alignSelf: 'flex-start', // Alinha o ícone com o topo
263
+ alignSelf: 'center',
264
264
  },
265
265
  iconContainerHidden: {
266
266
  width: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vpt-sebraeds",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "Biblioteca de componentes React Native do Sebrae",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",