react-native-exp-fig 0.1.21 → 0.1.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.
Files changed (95) hide show
  1. package/lib/commonjs/@types/as-base-component.js +12 -0
  2. package/lib/commonjs/@types/as-base-component.js.map +1 -0
  3. package/lib/commonjs/common/icons-svg/constants/index.js +2 -1
  4. package/lib/commonjs/common/icons-svg/constants/index.js.map +1 -1
  5. package/lib/commonjs/common/icons-svg/eclamation-triangle/index.js +33 -0
  6. package/lib/commonjs/common/icons-svg/eclamation-triangle/index.js.map +1 -0
  7. package/lib/commonjs/common/icons-svg/index.js +8 -0
  8. package/lib/commonjs/common/icons-svg/index.js.map +1 -1
  9. package/lib/commonjs/common/icons-svg/truck/index.js +2 -2
  10. package/lib/commonjs/common/icons-svg/truck/index.js.map +1 -1
  11. package/lib/commonjs/components/box/index.js +11 -11
  12. package/lib/commonjs/components/box/index.js.map +1 -1
  13. package/lib/commonjs/components/history-activities-card/index.js +197 -0
  14. package/lib/commonjs/components/history-activities-card/index.js.map +1 -0
  15. package/lib/commonjs/components/history-activities-card/interface.js +6 -0
  16. package/lib/commonjs/components/history-activities-card/interface.js.map +1 -0
  17. package/lib/commonjs/components/modal-change-activity/index.js +216 -0
  18. package/lib/commonjs/components/modal-change-activity/index.js.map +1 -0
  19. package/lib/commonjs/components/selects/select-option/index.js +28 -11
  20. package/lib/commonjs/components/selects/select-option/index.js.map +1 -1
  21. package/lib/commonjs/components/selects/select-option/interface.d.js.map +1 -1
  22. package/lib/commonjs/components/step-indicator/index.js +45 -7
  23. package/lib/commonjs/components/step-indicator/index.js.map +1 -1
  24. package/lib/commonjs/helpers/text-utils.js +21 -0
  25. package/lib/commonjs/helpers/text-utils.js.map +1 -0
  26. package/lib/commonjs/index.js +14 -0
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/commonjs/stories/history-activities-card/history-activities-card.stories.js +104 -0
  29. package/lib/commonjs/stories/history-activities-card/history-activities-card.stories.js.map +1 -0
  30. package/lib/commonjs/stories/modal-change-activity/modal-change-activity.stories.js +52 -0
  31. package/lib/commonjs/stories/modal-change-activity/modal-change-activity.stories.js.map +1 -0
  32. package/lib/commonjs/utils/get-icon-by-property/index.js.map +1 -1
  33. package/lib/module/@types/as-base-component.js +6 -0
  34. package/lib/module/@types/as-base-component.js.map +1 -0
  35. package/lib/module/common/icons-svg/constants/index.js +2 -1
  36. package/lib/module/common/icons-svg/constants/index.js.map +1 -1
  37. package/lib/module/common/icons-svg/eclamation-triangle/index.js +25 -0
  38. package/lib/module/common/icons-svg/eclamation-triangle/index.js.map +1 -0
  39. package/lib/module/common/icons-svg/index.js +8 -0
  40. package/lib/module/common/icons-svg/index.js.map +1 -1
  41. package/lib/module/common/icons-svg/truck/index.js +2 -2
  42. package/lib/module/common/icons-svg/truck/index.js.map +1 -1
  43. package/lib/module/components/box/index.js +10 -8
  44. package/lib/module/components/box/index.js.map +1 -1
  45. package/lib/module/components/history-activities-card/index.js +190 -0
  46. package/lib/module/components/history-activities-card/index.js.map +1 -0
  47. package/lib/module/components/history-activities-card/interface.js +2 -0
  48. package/lib/module/components/history-activities-card/interface.js.map +1 -0
  49. package/lib/module/components/modal-change-activity/index.js +207 -0
  50. package/lib/module/components/modal-change-activity/index.js.map +1 -0
  51. package/lib/module/components/selects/select-option/index.js +28 -11
  52. package/lib/module/components/selects/select-option/index.js.map +1 -1
  53. package/lib/module/components/selects/select-option/interface.d.js.map +1 -1
  54. package/lib/module/components/step-indicator/index.js +45 -7
  55. package/lib/module/components/step-indicator/index.js.map +1 -1
  56. package/lib/module/helpers/text-utils.js +14 -0
  57. package/lib/module/helpers/text-utils.js.map +1 -0
  58. package/lib/module/index.js +4 -2
  59. package/lib/module/index.js.map +1 -1
  60. package/lib/module/stories/history-activities-card/history-activities-card.stories.js +97 -0
  61. package/lib/module/stories/history-activities-card/history-activities-card.stories.js.map +1 -0
  62. package/lib/module/stories/modal-change-activity/modal-change-activity.stories.js +45 -0
  63. package/lib/module/stories/modal-change-activity/modal-change-activity.stories.js.map +1 -0
  64. package/lib/module/utils/get-icon-by-property/index.js +0 -1
  65. package/lib/module/utils/get-icon-by-property/index.js.map +1 -1
  66. package/lib/typescript/src/@types/as-base-component.d.ts +2 -0
  67. package/lib/typescript/src/common/icons-svg/constants/index.d.ts +1 -0
  68. package/lib/typescript/src/common/icons-svg/eclamation-triangle/index.d.ts +4 -0
  69. package/lib/typescript/src/components/box/index.d.ts +3 -5
  70. package/lib/typescript/src/components/history-activities-card/index.d.ts +76 -0
  71. package/lib/typescript/src/components/history-activities-card/interface.d.ts +120 -0
  72. package/lib/typescript/src/components/modal-change-activity/index.d.ts +24 -0
  73. package/lib/typescript/src/helpers/text-utils.d.ts +7 -0
  74. package/lib/typescript/src/index.d.ts +2 -0
  75. package/lib/typescript/src/stories/history-activities-card/history-activities-card.stories.d.ts +10 -0
  76. package/lib/typescript/src/stories/modal-change-activity/modal-change-activity.stories.d.ts +9 -0
  77. package/lib/typescript/src/utils/get-icon-by-property/index.d.ts +2 -1
  78. package/package.json +11 -8
  79. package/src/@types/as-base-component.ts +9 -0
  80. package/src/common/icons-svg/constants/index.ts +1 -0
  81. package/src/common/icons-svg/eclamation-triangle/index.tsx +46 -0
  82. package/src/common/icons-svg/index.tsx +5 -1
  83. package/src/common/icons-svg/truck/index.tsx +2 -2
  84. package/src/components/box/index.tsx +49 -47
  85. package/src/components/history-activities-card/index.tsx +217 -0
  86. package/src/components/history-activities-card/interface.ts +147 -0
  87. package/src/components/modal-change-activity/index.tsx +202 -0
  88. package/src/components/selects/select-option/index.tsx +115 -100
  89. package/src/components/selects/select-option/interface.d.ts +18 -18
  90. package/src/components/step-indicator/index.tsx +63 -7
  91. package/src/helpers/text-utils.ts +15 -0
  92. package/src/index.ts +45 -43
  93. package/src/stories/history-activities-card/history-activities-card.stories.tsx +107 -0
  94. package/src/stories/modal-change-activity/modal-change-activity.stories.tsx +52 -0
  95. package/src/utils/get-icon-by-property/index.tsx +13 -1
@@ -0,0 +1,147 @@
1
+ /**
2
+ * IMPORTS
3
+ */
4
+ import type React from "react";
5
+ import { type DimensionValue, type ViewProps } from "react-native";
6
+ import type { PropertyType } from "../../utils/get-icon-by-property";
7
+
8
+ /**
9
+ * INTERFACE
10
+ */
11
+
12
+ type ICardActivitiesWeek = ViewProps & {
13
+ /**
14
+ * props que mostra o nome do usuário
15
+ */
16
+ name?: string;
17
+
18
+ /**
19
+ * props que mostra o ciclo do relatório - DIÁRIA OU SEMANAL
20
+ */
21
+ ciclo?: string;
22
+
23
+ /**
24
+ * props que mostra a data
25
+ */
26
+ data_start: string;
27
+ data_end?: string | null;
28
+ duration: string;
29
+ status?: string;
30
+ name_activitie: string;
31
+ referencia: PropertyType;
32
+ type_activitie: string;
33
+ avatar?: string;
34
+ idAtividade: number;
35
+
36
+ children?: React.ReactNode;
37
+
38
+ /**
39
+ * TestID para testes automático e identificação
40
+ */
41
+ testID?: string;
42
+
43
+ /**
44
+ * A propriedade CSS abreviada border define a borda de um elemento. Ele define os valores de largura da borda, estilo da borda e cor da borda.
45
+ */
46
+ borderStyled?: {
47
+ borderStyle?: "solid" | "dotted" | "dashed";
48
+
49
+ borderRadius?: number | DimensionValue;
50
+ borderTopRightRadius?: number | DimensionValue;
51
+ borderTopLeftRadius?: number | DimensionValue;
52
+ borderBottomRightRadius?: number | DimensionValue;
53
+ borderBottomLeftRadius?: number | DimensionValue;
54
+
55
+ borderWidth?: number | DimensionValue;
56
+ borderLeftWidth?: number | DimensionValue;
57
+ borderRightWidth?: number | DimensionValue;
58
+ borderTopWidth?: number | DimensionValue;
59
+ borderBottomWidth?: number | DimensionValue;
60
+
61
+ borderColor?: string;
62
+ borderBottomColor?: string;
63
+ borderLeftColor?: string;
64
+ borderRightColor?: string;
65
+ borderTopColor?: string;
66
+ };
67
+
68
+ /**
69
+ * Propriedades que define a orientação do button que é usada para representar uma página. Na maioria das vezes, esse valores corresponde ao posicionamento alvo da página impressa, se aplicável.
70
+ */
71
+ flexStyle?: {
72
+ alignItems?: "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
73
+ alignSelf?: "auto" | "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
74
+ flex?: string | number;
75
+ flexDirection?: "column" | "column-reverse" | "row" | "row-reverse";
76
+ flexWrap?: "nowrap" | "wrap" | "wrap-reverse";
77
+ textAlign?: "auto" | "center" | "left" | "right" | "justify";
78
+ justifyContent?:
79
+ | "flex-start"
80
+ | "flex-end"
81
+ | "center"
82
+ | "space-between"
83
+ | "space-around"
84
+ | "space-evenly";
85
+ };
86
+
87
+ /**
88
+ * A propriedade margin do CSS define a área de margem nos quatro lados do elemento. É uma abreviação que define todas as margens individuais de uma só vez: margin-top, margin-right (en-US), margin-bottom, e margin-left (en-US).
89
+ */
90
+ marginStyle?: {
91
+ margin?: number | DimensionValue;
92
+ marginLeft?: number | DimensionValue;
93
+ marginRight?: number | DimensionValue;
94
+ marginTop?: number | DimensionValue;
95
+ marginBottom?: number | DimensionValue;
96
+ };
97
+
98
+ /**
99
+ * A propriedade padding define uma a distância entre o conteúdo de um elemento e suas bordas. É um atalho que evita definir uma distância para cada lado separadamente (padding-top, padding-right, padding-bottom, padding-left).
100
+ */
101
+ paddingStyle?: {
102
+ padding?: number | DimensionValue;
103
+ paddingLeft?: number | DimensionValue;
104
+ paddingRight?: number | DimensionValue;
105
+ paddingTop?: number | DimensionValue;
106
+ paddingBottom?: number | DimensionValue;
107
+ };
108
+
109
+ /**
110
+ * A propriedade CSS height define a altura de um elemento. A altura de um elemento é a distância do topo da borda superior do elemento ao fundo da borda inferior.
111
+ */
112
+ height?: number | DimensionValue;
113
+
114
+ /**
115
+ * A propriedade CSS width define a largura de um elemento. A largura de um elemento é a distância do topo da borda esquerda do elemento ao fundo da borda direita.
116
+ */
117
+ width?: number | DimensionValue;
118
+
119
+ /**
120
+ * O fundo abreviado CSS Propriedade define todas as propriedades do estilo de fundo de uma só vez, como cor, imagem, origem e tamanho ou método de repetição. As propriedades dos componentes não definidas no fundo da declaração de valor da propriedade abreviada são definidas como seus valores padrão..
121
+ * A Propriedade Background está sendo utilizada para definir a cor de fundo do cabeçalho do card e do ícone check.
122
+ */
123
+ backgroundColor?: string;
124
+
125
+ /**
126
+ * Propriedade texto que sera renderizado pro usuário final
127
+ */
128
+ text?: string;
129
+
130
+ /**
131
+ * A propriedade CSS color define o valor da cor de primeiro plano do texto e das decorações de texto de um elemento e define o valor currentcolor. currentcolor pode ser usado como um valor indireto em outras propriedades e é o padrão para outras propriedades de cores, como border-color.
132
+ */
133
+ color?: {
134
+ colorSvg?: string;
135
+ colorText?: string;
136
+ colorTextBold?: string;
137
+ colorTextData?: string;
138
+ };
139
+
140
+ // Cor do ícone CHECK
141
+ iconColor?: string;
142
+ };
143
+
144
+ /**
145
+ * EXPORT
146
+ */
147
+ export type { ICardActivitiesWeek };
@@ -0,0 +1,202 @@
1
+ /**
2
+ * IMPORTS
3
+ */
4
+ import React from "react";
5
+ // libs RN
6
+ import { Modal, View } from "react-native";
7
+
8
+ // componentes internos
9
+ import { Box } from "../box";
10
+ import { Typography } from "../typography";
11
+ import { SelectOption } from "../selects/select-option";
12
+ import { Button } from "../button";
13
+
14
+ // styles / theme
15
+ import { theme } from "../../styles/theme/theme";
16
+
17
+ // assets / icons
18
+ import { Icons } from "../../common/icons-svg";
19
+
20
+ /**
21
+ * TYPES
22
+ */
23
+ interface IModalChangeActivityProps {
24
+ visible: boolean;
25
+ onClose: () => void;
26
+ modalConfirm: (newData: { label: string; value: string; key: number }) => void;
27
+ dataRegistro: string;
28
+ descricao: string;
29
+ imagemUrl?: string;
30
+ }
31
+
32
+ /**
33
+ * CONSTANTS
34
+ */
35
+ const options = [
36
+ { label: "Selecione atividade", value: "none", key: 0 },
37
+ { label: "Descanso", value: "descanso", key: 5 },
38
+ { label: "Repouso Noturno", value: "repouso_noturno", key: 6 },
39
+ { label: "Refeição", value: "refeição", key: 7 },
40
+ { label: "Repouso Semanal", value: "repouso_semanal", key: 9 },
41
+ ];
42
+
43
+ /**
44
+ * COMPONENT
45
+ */
46
+ export const ModalChangeActivity: React.FC<IModalChangeActivityProps> = ({
47
+ visible,
48
+ onClose,
49
+ modalConfirm,
50
+ descricao,
51
+ }) => {
52
+ const [isLoading] = React.useState(false);
53
+
54
+ const initial = (descricao ?? "").toLowerCase().replace(/\s+/g, "_");
55
+ const [selectedOption, setSelectedOption] = React.useState(initial || "none");
56
+
57
+ const handleConfirm = () => {
58
+ const selected = options.find((opt) => opt.value === selectedOption);
59
+ if (selected && selected.value !== "none") {
60
+ modalConfirm({
61
+ label: selected.label,
62
+ value: selected.value,
63
+ key: selected.key,
64
+ });
65
+ }
66
+ onClose();
67
+ };
68
+
69
+ return (
70
+ <Modal animationType="fade" transparent visible={visible}>
71
+ <View
72
+ style={{
73
+ flex: 1,
74
+ justifyContent: "center",
75
+ alignItems: "center",
76
+ backgroundColor: "rgba(0,0,0,0.6)",
77
+ }}
78
+ >
79
+ <Box
80
+ width={346}
81
+ backgroundColor={theme.colors.orange[500]}
82
+ borderStyled={{
83
+ borderRadius: theme.borderWidths.thick_medium,
84
+ }}
85
+ paddingStyle={{
86
+ paddingLeft: theme.paddings["2xs"],
87
+ paddingRight: theme.paddings["2xs"],
88
+ paddingTop: theme.paddings.sm,
89
+ paddingBottom: theme.paddings.sm,
90
+ }}
91
+ >
92
+ <Box
93
+ marginStyle={{ marginBottom: theme.margins["2xs"], marginLeft: theme.margins["1xs"] }}
94
+ flexStyle={{ flexDirection: "row", alignItems: "center" }}
95
+ >
96
+ <Icons
97
+ icon="EXCLAMATION_TRIANGLE"
98
+ color={theme.colors.black[10]}
99
+ background={theme.colors.yellow[50]}
100
+ size={22}
101
+ />
102
+ <Typography
103
+ text="Alterar Atividade"
104
+ color="#fff"
105
+ marginLeft={theme.margins["2xs"]}
106
+ fontFamily={theme.fonts.inter_bold_700}
107
+ size={theme.fontSizes.md}
108
+ />
109
+ </Box>
110
+
111
+ <Box
112
+ backgroundColor={theme.colors.neutral[300]}
113
+ paddingStyle={{ padding: theme.paddings.xs }}
114
+ borderStyled={{ borderRadius: theme.borderWidths.thick_medium }}
115
+ >
116
+ <Box
117
+ flexStyle={{ flexDirection: "row", justifyContent: "flex-start" }}
118
+ width={"90%"}
119
+ >
120
+ <Typography
121
+ text={`Deseja realmente alterar sua atividade de ${descricao || "atividade atual"}?`}
122
+ color={theme.colors.black[25]}
123
+ fontFamily={theme.fonts.inter_medium_500}
124
+ size={theme.fontSizes.xs}
125
+ style={{ flexWrap: "wrap", maxWidth: "100%" }}
126
+ />
127
+ </Box>
128
+
129
+ <SelectOption
130
+ titleLabel="Selecione atividade"
131
+ sizeTitleLabel={theme.fontSizes.xs}
132
+ dataOption={options}
133
+ handleSelectDown={(opt) => {
134
+ const option = options.find((o) => o.label === opt || o.value === opt);
135
+ if (option) setSelectedOption(option.value);
136
+ }}
137
+ backgroundColor={theme.colors.neutral[300]}
138
+ />
139
+
140
+ <Box
141
+ marginStyle={{ marginTop: theme.margins["1xs"]}}
142
+ flexStyle={{ flexDirection: "row", justifyContent: "space-between" }}
143
+ >
144
+ <Button
145
+ title="CANCELAR"
146
+ onPress={onClose}
147
+ width={"48%"}
148
+ height={36}
149
+ isLoading={isLoading}
150
+ disabled={isLoading}
151
+ backgroundColor={theme.colors.neutral[300]}
152
+ buttonTextStyle={{
153
+ color: theme.colors.blue[100],
154
+ fontFamily: "Inter-Medium",
155
+ fontSize: theme.fontSizes.xs,
156
+ fontWeight: "500",
157
+ }}
158
+ flexStyle={{
159
+ flexDirection: "row",
160
+ alignItems: "center",
161
+ justifyContent: "center",
162
+ textAlign: "center",
163
+ }}
164
+ borderStyled={{
165
+ borderWidth: theme.borderWidths.thin,
166
+ borderColor: theme.colors.blue[100],
167
+ borderRadius: theme.borderWidths.thick_medium,
168
+ }}
169
+ />
170
+ <Button
171
+ title="CONFIRMAR"
172
+ onPress={handleConfirm}
173
+ width={"48%"}
174
+ height={36}
175
+ isLoading={isLoading}
176
+ disabled={isLoading}
177
+ backgroundColor={theme.colors.blue[100]}
178
+ buttonTextStyle={{
179
+ color: "#fff",
180
+ fontFamily: "Inter-Medium",
181
+ fontSize: theme.fontSizes.xs,
182
+ fontWeight: "500",
183
+ }}
184
+ flexStyle={{
185
+ flexDirection: "row",
186
+ alignItems: "center",
187
+ justifyContent: "center",
188
+ textAlign: "center",
189
+ }}
190
+ borderStyled={{
191
+ borderWidth: theme.borderWidths.thin,
192
+ borderColor: theme.colors.blue[100],
193
+ borderRadius: theme.borderWidths.thick_medium,
194
+ }}
195
+ />
196
+ </Box>
197
+ </Box>
198
+ </Box>
199
+ </View>
200
+ </Modal>
201
+ );
202
+ };
@@ -1,100 +1,115 @@
1
- /**
2
- * IMPORTS
3
- */
4
- import React from "react";
5
- import { useState } from "react";
6
- import { View, Text, TouchableOpacity, Modal, FlatList } from "react-native";
7
-
8
- // typings
9
- import { ISelectDropDownProps } from "./interface";
10
-
11
- // styles
12
- import { styles } from "./styles";
13
- import { Icons } from "../../../common/icons-svg";
14
- import { theme } from "../../../styles/theme/theme";
15
-
16
- /**
17
- * Componente SelectOption para a interação da ui.
18
- */
19
- const SelectOption: React.FC<ISelectDropDownProps> = ({
20
- dataOption,
21
- handleSelectDown,
22
- titleLabel,
23
- sizeTitleLabel,
24
- colortitleLabel,
25
- }: ISelectDropDownProps) => {
26
- const [selectedValue, setSelectedValue] = useState(dataOption[0]?.value || "");
27
- const [modalVisible, setModalVisible] = useState(false);
28
-
29
- const handleSelect = (value: string) => {
30
- setSelectedValue(value);
31
- setModalVisible(false);
32
- handleSelectDown(value);
33
- };
34
-
35
- const styleProps = {
36
- dataOption,
37
- handleSelectDown,
38
- titleLabel,
39
- sizeTitleLabel,
40
- colortitleLabel,
41
- } as ISelectDropDownProps;
42
-
43
- return (
44
- <View style={styles(styleProps).container}>
45
- {/* Titulo para exibir o label */}
46
- <Text style={styles(styleProps).label}>{`${titleLabel ?? "Selecione uma opção"}`}:</Text>
47
-
48
- {/* Botão para abrir o modal */}
49
- <TouchableOpacity
50
- testID="select-box"
51
- style={styles(styleProps).selectBox}
52
- onPress={() => setModalVisible(true)}
53
- >
54
- <Text style={styles(styleProps).selectedText}>
55
- {dataOption.find((item) => item.value === selectedValue)?.label}
56
- </Text>
57
-
58
- <Icons
59
- size={theme.fontSizes["md"]}
60
- color={theme.colors.blue[500]}
61
- icon={"ARROW_DROP_DOWN"}
62
- />
63
- </TouchableOpacity>
64
-
65
- {/* Modal para exibir as opções */}
66
- <Modal testID="modal-container" visible={modalVisible} transparent animationType="fade">
67
- <View style={styles(styleProps).modalOverlay}>
68
- <View style={styles(styleProps).modalContainer}>
69
- <View style={{ width: "100%", alignItems: "flex-end" }}>
70
- <TouchableOpacity testID="close-icon" onPress={() => setModalVisible(false)}>
71
- <Icons
72
- size={theme.fontSizes["md"]}
73
- color={theme.colors.blue[500]}
74
- icon={"CLOSED"}
75
- />
76
- </TouchableOpacity>
77
- </View>
78
- <FlatList
79
- data={dataOption || []}
80
- keyExtractor={(item) => item.value}
81
- renderItem={({ item }) => (
82
- <TouchableOpacity
83
- style={styles(styleProps).option}
84
- onPress={() => handleSelect(item.value)}
85
- >
86
- <Text style={styles(styleProps).optionText}>{item.label}</Text>
87
- </TouchableOpacity>
88
- )}
89
- />
90
- </View>
91
- </View>
92
- </Modal>
93
- </View>
94
- );
95
- };
96
-
97
- /**
98
- * EXPORTS
99
- */
100
- export { SelectOption };
1
+ /**
2
+ * IMPORTS
3
+ */
4
+ import React from "react";
5
+ import { useState } from "react";
6
+ import { View, Text, TouchableOpacity, Modal, FlatList } from "react-native";
7
+
8
+ // typings
9
+ import { ISelectDropDownProps } from "./interface";
10
+
11
+ // styles
12
+ import { styles } from "./styles";
13
+ import { Icons } from "../../../common/icons-svg";
14
+ import { theme } from "../../../styles/theme/theme";
15
+
16
+ /**
17
+ * Componente SelectOption para a interação da ui.
18
+ */
19
+ const SelectOption: React.FC<ISelectDropDownProps> = ({
20
+ dataOption,
21
+ handleSelectDown,
22
+ titleLabel,
23
+ sizeTitleLabel,
24
+ colortitleLabel,
25
+ backgroundColor,
26
+ }: ISelectDropDownProps) => {
27
+ const [selectedValue, setSelectedValue] = useState(dataOption[0]?.value || "");
28
+ const [modalVisible, setModalVisible] = useState(false);
29
+
30
+ const handleSelect = (value: string) => {
31
+ setSelectedValue(value);
32
+ setModalVisible(false);
33
+ handleSelectDown(value);
34
+ };
35
+
36
+ const styleProps = {
37
+ dataOption,
38
+ handleSelectDown,
39
+ titleLabel,
40
+ sizeTitleLabel,
41
+ colortitleLabel,
42
+ backgroundColor,
43
+ } as ISelectDropDownProps;
44
+
45
+ return (
46
+ <View style={styles(styleProps).container}>
47
+ {/* Titulo para exibir o label */}
48
+ <Text style={styles(styleProps).label}>{`${titleLabel ?? "Selecione uma opção"}`}:</Text>
49
+
50
+ {/* Botão para abrir o modal */}
51
+ <TouchableOpacity
52
+ testID="select-box"
53
+ style={[styles(styleProps).selectBox, backgroundColor && { backgroundColor },]}
54
+ onPress={() => setModalVisible(true)}
55
+ >
56
+ <Text style={styles(styleProps).selectedText}>
57
+ {dataOption.find((item) => item.value === selectedValue)?.label}
58
+ </Text>
59
+
60
+ <Icons
61
+ size={theme.fontSizes["md"]}
62
+ color={theme.colors.blue[500]}
63
+ icon={"ARROW_DROP_DOWN"}
64
+ />
65
+ </TouchableOpacity>
66
+
67
+ {/* Modal para exibir as opções */}
68
+ <Modal testID="modal-container" visible={modalVisible} transparent animationType="fade">
69
+ <View style={styles(styleProps).modalOverlay}>
70
+ <View style={{
71
+ width: "90%",
72
+ backgroundColor: "#fff",
73
+ borderRadius: 8,
74
+ padding: 16,
75
+ maxHeight: "80%",
76
+ }}>
77
+ <View style={{ width: "100%", alignItems: "flex-end" }}>
78
+ <TouchableOpacity testID="close-icon" onPress={() => setModalVisible(false)}>
79
+ <Icons
80
+ size={theme.fontSizes["md"]}
81
+ color={theme.colors.blue[500]}
82
+ icon={"CLOSED"}
83
+ />
84
+ </TouchableOpacity>
85
+ </View>
86
+ <FlatList
87
+ data={dataOption || []}
88
+ keyExtractor={(item) => item.value}
89
+ renderItem={({ item }) => (
90
+ <TouchableOpacity
91
+ style={{
92
+ width: "100%",
93
+ paddingVertical: 12,
94
+ paddingHorizontal: 8,
95
+ alignItems: "flex-start",
96
+ borderBottomWidth: 1,
97
+ borderColor: "#eee",
98
+ }}
99
+ onPress={() => handleSelect(item.value)}
100
+ >
101
+ <Text style={styles(styleProps).optionText}>{item.label}</Text>
102
+ </TouchableOpacity>
103
+ )}
104
+ />
105
+ </View>
106
+ </View>
107
+ </Modal>
108
+ </View>
109
+ );
110
+ };
111
+
112
+ /**
113
+ * EXPORTS
114
+ */
115
+ export { SelectOption };
@@ -1,18 +1,18 @@
1
- /**
2
- * IMPORTS
3
- */
4
- type ISelectDropDownProps = {
5
- dataOption: any[];
6
- titleLabel: string;
7
- sizeTitleLabel?: number;
8
- colortitleLabel?: string;
9
-
10
- /**retorna o valor selecionado */
11
- // eslint-disable-next-line no-unused-vars
12
- handleSelectDown: (value: string) => void;
13
- };
14
-
15
- /**
16
- * EXPORTS
17
- */
18
- export { ISelectDropDownProps };
1
+ /**
2
+ * IMPORTS
3
+ */
4
+ type ISelectDropDownProps = {
5
+ dataOption: any[];
6
+ titleLabel: string;
7
+ sizeTitleLabel?: number;
8
+ colortitleLabel?: string;
9
+ backgroundColor?: string;
10
+ /**retorna o valor selecionado */
11
+ // eslint-disable-next-line no-unused-vars
12
+ handleSelectDown: (value: string) => void;
13
+ };
14
+
15
+ /**
16
+ * EXPORTS
17
+ */
18
+ export { ISelectDropDownProps };