react-native-exp-fig 0.1.37 → 0.1.39
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/lib/commonjs/components/modal-create-activitie/index.js +13 -11
- package/lib/commonjs/components/modal-create-activitie/index.js.map +1 -1
- package/lib/commonjs/components/modal-create-activitie/interface.js.map +1 -1
- package/lib/commonjs/components/modal-journey-rectification/index.js +10 -10
- package/lib/commonjs/components/modal-journey-rectification/index.js.map +1 -1
- package/lib/commonjs/components/modals/modal-activities/data-activities/index.js +25 -1
- package/lib/commonjs/components/modals/modal-activities/data-activities/index.js.map +1 -1
- package/lib/commonjs/components/modals/modal-activity-reason/index.js +6 -5
- package/lib/commonjs/components/modals/modal-activity-reason/index.js.map +1 -1
- package/lib/commonjs/components/modals/modal-activity-reason/interface.d.js.map +1 -1
- package/lib/commonjs/components/modals/modal-change-activity/index.js.map +1 -1
- package/lib/commonjs/components/selects/select-option/index.js +4 -4
- package/lib/commonjs/components/selects/select-option/index.js.map +1 -1
- package/lib/commonjs/components/selects/select-option/interface.d.js.map +1 -1
- package/lib/commonjs/stories/modal-activity-reason/modal-activity-reason.stories.js +8 -8
- package/lib/commonjs/stories/modal-activity-reason/modal-activity-reason.stories.js.map +1 -1
- package/lib/commonjs/stories/modal-create-activitie/modal-create-activitie.stories.js +5 -1
- package/lib/commonjs/stories/modal-create-activitie/modal-create-activitie.stories.js.map +1 -1
- package/lib/module/components/modal-create-activitie/index.js +13 -11
- package/lib/module/components/modal-create-activitie/index.js.map +1 -1
- package/lib/module/components/modal-create-activitie/interface.js.map +1 -1
- package/lib/module/components/modal-journey-rectification/index.js +10 -10
- package/lib/module/components/modal-journey-rectification/index.js.map +1 -1
- package/lib/module/components/modals/modal-activities/data-activities/index.js +24 -0
- package/lib/module/components/modals/modal-activities/data-activities/index.js.map +1 -1
- package/lib/module/components/modals/modal-activity-reason/index.js +6 -5
- package/lib/module/components/modals/modal-activity-reason/index.js.map +1 -1
- package/lib/module/components/modals/modal-activity-reason/interface.d.js.map +1 -1
- package/lib/module/components/modals/modal-change-activity/index.js.map +1 -1
- package/lib/module/components/selects/select-option/index.js +4 -4
- package/lib/module/components/selects/select-option/index.js.map +1 -1
- package/lib/module/components/selects/select-option/interface.d.js.map +1 -1
- package/lib/module/stories/modal-activity-reason/modal-activity-reason.stories.js +8 -8
- package/lib/module/stories/modal-activity-reason/modal-activity-reason.stories.js.map +1 -1
- package/lib/module/stories/modal-create-activitie/modal-create-activitie.stories.js +5 -1
- package/lib/module/stories/modal-create-activitie/modal-create-activitie.stories.js.map +1 -1
- package/lib/typescript/src/components/modals/modal-activities/data-activities/index.d.ts +7 -0
- package/package.json +4 -8
- package/src/components/modal-create-activitie/index.tsx +215 -211
- package/src/components/modal-create-activitie/interface.ts +22 -22
- package/src/components/modal-journey-rectification/index.tsx +213 -211
- package/src/components/modals/modal-activities/data-activities/index.ts +31 -0
- package/src/components/modals/modal-activity-reason/index.tsx +163 -162
- package/src/components/modals/modal-activity-reason/interface.d.ts +10 -10
- package/src/components/modals/modal-change-activity/index.tsx +1 -1
- package/src/components/selects/select-option/index.tsx +124 -124
- package/src/components/selects/select-option/interface.d.ts +18 -18
- package/src/stories/modal-activity-reason/modal-activity-reason.stories.tsx +192 -192
- package/src/stories/modal-create-activitie/modal-create-activitie.stories.tsx +4 -0
|
@@ -1,162 +1,163 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IMPORTS
|
|
3
|
-
*/
|
|
4
|
-
import React, { useState } from "react";
|
|
5
|
-
import { Modal, View } from "react-native";
|
|
6
|
-
|
|
7
|
-
// components
|
|
8
|
-
import Box from "../../box";
|
|
9
|
-
import { Typography } from "../../typography";
|
|
10
|
-
import { Button } from "../../button";
|
|
11
|
-
|
|
12
|
-
import InputTextCounter from "../../input-text-counter";
|
|
13
|
-
|
|
14
|
-
// commons / svg
|
|
15
|
-
import { Icons } from "../../../common/icons-svg";
|
|
16
|
-
|
|
17
|
-
// typings
|
|
18
|
-
import type { IModalActivityReasonProps } from "./interface";
|
|
19
|
-
|
|
20
|
-
// styles
|
|
21
|
-
import { theme } from "../../../styles/theme/theme";
|
|
22
|
-
|
|
23
|
-
const ModalActivityReason: React.FC<IModalActivityReasonProps> = ({
|
|
24
|
-
visible,
|
|
25
|
-
onClose,
|
|
26
|
-
modalConfirm,
|
|
27
|
-
textTitle,
|
|
28
|
-
testID,
|
|
29
|
-
}) => {
|
|
30
|
-
const [isLoading] = useState(false);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
1
|
+
/**
|
|
2
|
+
* IMPORTS
|
|
3
|
+
*/
|
|
4
|
+
import React, { useState } from "react";
|
|
5
|
+
import { Modal, View } from "react-native";
|
|
6
|
+
|
|
7
|
+
// components
|
|
8
|
+
import Box from "../../box";
|
|
9
|
+
import { Typography } from "../../typography";
|
|
10
|
+
import { Button } from "../../button";
|
|
11
|
+
|
|
12
|
+
import InputTextCounter from "../../input-text-counter";
|
|
13
|
+
|
|
14
|
+
// commons / svg
|
|
15
|
+
import { Icons } from "../../../common/icons-svg";
|
|
16
|
+
|
|
17
|
+
// typings
|
|
18
|
+
import type { IModalActivityReasonProps } from "./interface";
|
|
19
|
+
|
|
20
|
+
// styles
|
|
21
|
+
import { theme } from "../../../styles/theme/theme";
|
|
22
|
+
|
|
23
|
+
const ModalActivityReason: React.FC<IModalActivityReasonProps> = ({
|
|
24
|
+
visible,
|
|
25
|
+
onClose,
|
|
26
|
+
modalConfirm,
|
|
27
|
+
textTitle,
|
|
28
|
+
testID,
|
|
29
|
+
}) => {
|
|
30
|
+
const [isLoading] = useState(false);
|
|
31
|
+
const [description, setDescription] = useState("");
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Modal testID={testID} animationType="fade" transparent visible={visible}>
|
|
35
|
+
<View
|
|
36
|
+
style={{
|
|
37
|
+
flex: 1,
|
|
38
|
+
justifyContent: "center",
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
backgroundColor: "rgba(0,0,0,0.6)",
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<Box
|
|
44
|
+
width={"90%"}
|
|
45
|
+
backgroundColor={theme.colors.orange[500]}
|
|
46
|
+
borderStyled={{
|
|
47
|
+
borderRadius: theme.borderWidths.thick_medium,
|
|
48
|
+
}}
|
|
49
|
+
paddingStyle={{
|
|
50
|
+
paddingLeft: theme.paddings["2xs"],
|
|
51
|
+
paddingRight: theme.paddings["2xs"],
|
|
52
|
+
paddingTop: theme.paddings.sm,
|
|
53
|
+
paddingBottom: theme.paddings.sm,
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
<Box
|
|
57
|
+
marginStyle={{ marginBottom: 10, marginLeft: 4 }}
|
|
58
|
+
flexStyle={{ flexDirection: "row", alignItems: "center" }}
|
|
59
|
+
>
|
|
60
|
+
<Icons
|
|
61
|
+
icon="EXCLAMATION_TRIANGLE"
|
|
62
|
+
color={theme.colors.orange[500]}
|
|
63
|
+
background={theme.colors.neutral[300]}
|
|
64
|
+
size={22}
|
|
65
|
+
/>
|
|
66
|
+
<Typography
|
|
67
|
+
text={`${textTitle ?? "Motivo da exclusão"}`}
|
|
68
|
+
color={theme.colors.neutral[25]}
|
|
69
|
+
marginLeft={theme.margins["2xs"]}
|
|
70
|
+
fontFamily={theme.fonts.inter_bold_700}
|
|
71
|
+
size={theme.fontSizes.md}
|
|
72
|
+
/>
|
|
73
|
+
</Box>
|
|
74
|
+
|
|
75
|
+
<Box
|
|
76
|
+
backgroundColor={theme.colors.neutral[300]}
|
|
77
|
+
paddingStyle={{
|
|
78
|
+
padding: theme.paddings.xs,
|
|
79
|
+
}}
|
|
80
|
+
borderStyled={{
|
|
81
|
+
borderRadius: theme.borderWidths.thick_medium,
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
84
|
+
<Box width="100%">
|
|
85
|
+
<InputTextCounter
|
|
86
|
+
label={`${textTitle || "Motivo da exclusão"}`}
|
|
87
|
+
placeholderTextColor="#9B9B9B"
|
|
88
|
+
placeholder="Motivo da exclusão"
|
|
89
|
+
onChangeText={setDescription}
|
|
90
|
+
/>
|
|
91
|
+
</Box>
|
|
92
|
+
<Box
|
|
93
|
+
marginStyle={{ marginTop: 4 }}
|
|
94
|
+
flexStyle={{
|
|
95
|
+
flexDirection: "row",
|
|
96
|
+
justifyContent: "space-between",
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
<Button
|
|
100
|
+
title="CANCELAR"
|
|
101
|
+
onPress={onClose}
|
|
102
|
+
width={"48%"}
|
|
103
|
+
height={40}
|
|
104
|
+
isLoading={isLoading}
|
|
105
|
+
disabled={isLoading}
|
|
106
|
+
backgroundColor={theme.colors.neutral[300]}
|
|
107
|
+
buttonTextStyle={{
|
|
108
|
+
color: theme.colors.blue[100],
|
|
109
|
+
fontFamily: "Inter-Medium",
|
|
110
|
+
fontSize: theme.fontSizes.xs,
|
|
111
|
+
fontWeight: "500",
|
|
112
|
+
}}
|
|
113
|
+
flexStyle={{
|
|
114
|
+
flexDirection: "row",
|
|
115
|
+
alignItems: "center",
|
|
116
|
+
justifyContent: "center",
|
|
117
|
+
textAlign: "center",
|
|
118
|
+
}}
|
|
119
|
+
borderStyled={{
|
|
120
|
+
borderWidth: theme.borderWidths.thin,
|
|
121
|
+
borderColor: theme.colors.blue[100],
|
|
122
|
+
borderRadius: theme.borderWidths.thick_medium,
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
125
|
+
<Button
|
|
126
|
+
title="CONFIRMAR"
|
|
127
|
+
onPress={() => {
|
|
128
|
+
modalConfirm(description);
|
|
129
|
+
}}
|
|
130
|
+
width={"48%"}
|
|
131
|
+
height={40}
|
|
132
|
+
isLoading={isLoading}
|
|
133
|
+
disabled={isLoading}
|
|
134
|
+
backgroundColor={theme.colors.blue[500]}
|
|
135
|
+
buttonTextStyle={{
|
|
136
|
+
color: theme.colors.neutral[25],
|
|
137
|
+
fontFamily: "Inter-Medium",
|
|
138
|
+
fontSize: theme.fontSizes.xs,
|
|
139
|
+
fontWeight: "500",
|
|
140
|
+
}}
|
|
141
|
+
flexStyle={{
|
|
142
|
+
flexDirection: "row",
|
|
143
|
+
alignItems: "center",
|
|
144
|
+
justifyContent: "center",
|
|
145
|
+
textAlign: "center",
|
|
146
|
+
}}
|
|
147
|
+
borderStyled={{
|
|
148
|
+
borderWidth: theme.borderWidths.thin,
|
|
149
|
+
borderColor: theme.colors.blue[100],
|
|
150
|
+
borderRadius: theme.borderWidths.thick_medium,
|
|
151
|
+
}}
|
|
152
|
+
/>
|
|
153
|
+
</Box>
|
|
154
|
+
</Box>
|
|
155
|
+
</Box>
|
|
156
|
+
</View>
|
|
157
|
+
</Modal>
|
|
158
|
+
);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
ModalActivityReason.displayName = "ModalActivityReason";
|
|
162
|
+
|
|
163
|
+
export default ModalActivityReason;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
interface IModalActivityReasonProps {
|
|
3
|
-
visible: boolean;
|
|
4
|
-
onClose: () => void;
|
|
5
|
-
modalConfirm: (value:
|
|
6
|
-
textTitle?: string;
|
|
7
|
-
testID?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type { IModalActivityReasonProps };
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
interface IModalActivityReasonProps {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
modalConfirm: (value: string) => void;
|
|
6
|
+
textTitle?: string;
|
|
7
|
+
testID?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type { IModalActivityReasonProps };
|
|
@@ -126,7 +126,7 @@ export const ModalChangeActivity: React.FC<IModalChangeActivityProps> = ({
|
|
|
126
126
|
titleLabel="Selecione atividade"
|
|
127
127
|
sizeTitleLabel={theme.fontSizes.xs}
|
|
128
128
|
dataOption={options}
|
|
129
|
-
handleSelectDown={(opt) => {
|
|
129
|
+
handleSelectDown={(opt: any) => {
|
|
130
130
|
const option = options.find((o) => o.label === opt || o.value === opt);
|
|
131
131
|
if (option) setSelectedOption(option.value);
|
|
132
132
|
}}
|
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IMPORTS
|
|
3
|
-
*/
|
|
4
|
-
import React, { forwardRef, useState } from "react";
|
|
5
|
-
import { View, Text, TouchableOpacity, Modal, FlatList } from "react-native";
|
|
6
|
-
|
|
7
|
-
// commons / svg
|
|
8
|
-
import { Icons } from "../../../common/icons-svg";
|
|
9
|
-
|
|
10
|
-
// utils
|
|
11
|
-
import { handleLimitTextdisplayByAmount } from "../../../utils/text-limit";
|
|
12
|
-
|
|
13
|
-
// typings
|
|
14
|
-
import { asBaseComponent } from "../../../@types/as-base-component";
|
|
15
|
-
import type { ISelectDropDownProps } from "./interface";
|
|
16
|
-
|
|
17
|
-
// styles
|
|
18
|
-
import { styles } from "./styles";
|
|
19
|
-
import { theme } from "../../../styles/theme/theme";
|
|
20
|
-
|
|
21
|
-
const SelectOption = forwardRef<any, ISelectDropDownProps>((props, ref): React.ReactElement => {
|
|
22
|
-
const {
|
|
23
|
-
dataOption,
|
|
24
|
-
handleSelectDown,
|
|
25
|
-
titleLabel,
|
|
26
|
-
sizeTitleLabel,
|
|
27
|
-
colortitleLabel,
|
|
28
|
-
backgroundColor,
|
|
29
|
-
} = props;
|
|
30
|
-
|
|
31
|
-
const [selectedValue, setSelectedValue] = useState(dataOption[0]?.value || "");
|
|
32
|
-
const [modalVisible, setModalVisible] = useState(false);
|
|
33
|
-
|
|
34
|
-
const handleSelect = (value:
|
|
35
|
-
setSelectedValue(value);
|
|
36
|
-
setModalVisible(false);
|
|
37
|
-
handleSelectDown(value);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const styleProps = {
|
|
41
|
-
dataOption,
|
|
42
|
-
handleSelectDown,
|
|
43
|
-
titleLabel,
|
|
44
|
-
sizeTitleLabel,
|
|
45
|
-
colortitleLabel,
|
|
46
|
-
backgroundColor,
|
|
47
|
-
} as ISelectDropDownProps;
|
|
48
|
-
return (
|
|
49
|
-
<View ref={ref} style={styles(styleProps).container}>
|
|
50
|
-
{/* Titulo para exibir o label */}
|
|
51
|
-
<Text style={styles(styleProps).label}>{`${titleLabel ?? "Selecione uma opção"}`}:</Text>
|
|
52
|
-
|
|
53
|
-
{/* Botão para abrir o modal */}
|
|
54
|
-
<TouchableOpacity
|
|
55
|
-
testID="select-box"
|
|
56
|
-
style={styles(styleProps).selectBox}
|
|
57
|
-
onPress={() => setModalVisible(true)}
|
|
58
|
-
>
|
|
59
|
-
<Text style={styles(styleProps).selectedText} numberOfLines={1}>
|
|
60
|
-
{`${handleLimitTextdisplayByAmount({
|
|
61
|
-
limit: 42,
|
|
62
|
-
text: dataOption.find((item) => item.value === selectedValue)?.label!,
|
|
63
|
-
})}`}
|
|
64
|
-
</Text>
|
|
65
|
-
|
|
66
|
-
<Icons
|
|
67
|
-
size={theme.fontSizes["xs"]}
|
|
68
|
-
color={theme.colors.blue[500]}
|
|
69
|
-
icon={"ARROW_DROP_DOWN"}
|
|
70
|
-
/>
|
|
71
|
-
</TouchableOpacity>
|
|
72
|
-
|
|
73
|
-
{/* Modal para exibir as opções */}
|
|
74
|
-
<Modal testID="modal-container" visible={modalVisible} transparent animationType="fade">
|
|
75
|
-
<View style={styles(styleProps).modalOverlay}>
|
|
76
|
-
<View style={styles(styleProps).modalContainer}>
|
|
77
|
-
<View
|
|
78
|
-
style={{
|
|
79
|
-
width: "100%",
|
|
80
|
-
alignItems: "flex-end",
|
|
81
|
-
height: 40,
|
|
82
|
-
paddingRight: 8,
|
|
83
|
-
}}
|
|
84
|
-
>
|
|
85
|
-
<TouchableOpacity
|
|
86
|
-
testID="close-icon"
|
|
87
|
-
onPress={() => setModalVisible(false)}
|
|
88
|
-
style={{
|
|
89
|
-
width: 40,
|
|
90
|
-
height: 45,
|
|
91
|
-
alignItems: "center",
|
|
92
|
-
justifyContent: "center",
|
|
93
|
-
}}
|
|
94
|
-
>
|
|
95
|
-
<Icons
|
|
96
|
-
size={theme.fontSizes["md"]}
|
|
97
|
-
color={theme.colors.blue[500]}
|
|
98
|
-
icon={"CLOSED"}
|
|
99
|
-
/>
|
|
100
|
-
</TouchableOpacity>
|
|
101
|
-
</View>
|
|
102
|
-
<FlatList
|
|
103
|
-
data={dataOption || []}
|
|
104
|
-
keyExtractor={(item) => item.value}
|
|
105
|
-
renderItem={({ item }) => (
|
|
106
|
-
<TouchableOpacity
|
|
107
|
-
style={styles(styleProps).option}
|
|
108
|
-
onPress={() => handleSelect(item.value)}
|
|
109
|
-
>
|
|
110
|
-
<Text style={styles(styleProps).optionText}>{item.label}</Text>
|
|
111
|
-
</TouchableOpacity>
|
|
112
|
-
)}
|
|
113
|
-
/>
|
|
114
|
-
</View>
|
|
115
|
-
</View>
|
|
116
|
-
</Modal>
|
|
117
|
-
</View>
|
|
118
|
-
);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Componente SelectOption para a interação da ui.
|
|
123
|
-
*/
|
|
124
|
-
export default asBaseComponent(SelectOption);
|
|
1
|
+
/**
|
|
2
|
+
* IMPORTS
|
|
3
|
+
*/
|
|
4
|
+
import React, { forwardRef, useState } from "react";
|
|
5
|
+
import { View, Text, TouchableOpacity, Modal, FlatList } from "react-native";
|
|
6
|
+
|
|
7
|
+
// commons / svg
|
|
8
|
+
import { Icons } from "../../../common/icons-svg";
|
|
9
|
+
|
|
10
|
+
// utils
|
|
11
|
+
import { handleLimitTextdisplayByAmount } from "../../../utils/text-limit";
|
|
12
|
+
|
|
13
|
+
// typings
|
|
14
|
+
import { asBaseComponent } from "../../../@types/as-base-component";
|
|
15
|
+
import type { ISelectDropDownProps } from "./interface";
|
|
16
|
+
|
|
17
|
+
// styles
|
|
18
|
+
import { styles } from "./styles";
|
|
19
|
+
import { theme } from "../../../styles/theme/theme";
|
|
20
|
+
|
|
21
|
+
const SelectOption = forwardRef<any, ISelectDropDownProps>((props, ref): React.ReactElement => {
|
|
22
|
+
const {
|
|
23
|
+
dataOption,
|
|
24
|
+
handleSelectDown,
|
|
25
|
+
titleLabel,
|
|
26
|
+
sizeTitleLabel,
|
|
27
|
+
colortitleLabel,
|
|
28
|
+
backgroundColor,
|
|
29
|
+
} = props;
|
|
30
|
+
|
|
31
|
+
const [selectedValue, setSelectedValue] = useState(dataOption[0]?.value || "");
|
|
32
|
+
const [modalVisible, setModalVisible] = useState(false);
|
|
33
|
+
|
|
34
|
+
const handleSelect = (value: number) => {
|
|
35
|
+
setSelectedValue(value);
|
|
36
|
+
setModalVisible(false);
|
|
37
|
+
handleSelectDown(value);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const styleProps = {
|
|
41
|
+
dataOption,
|
|
42
|
+
handleSelectDown,
|
|
43
|
+
titleLabel,
|
|
44
|
+
sizeTitleLabel,
|
|
45
|
+
colortitleLabel,
|
|
46
|
+
backgroundColor,
|
|
47
|
+
} as ISelectDropDownProps;
|
|
48
|
+
return (
|
|
49
|
+
<View ref={ref} style={styles(styleProps).container}>
|
|
50
|
+
{/* Titulo para exibir o label */}
|
|
51
|
+
<Text style={styles(styleProps).label}>{`${titleLabel ?? "Selecione uma opção"}`}:</Text>
|
|
52
|
+
|
|
53
|
+
{/* Botão para abrir o modal */}
|
|
54
|
+
<TouchableOpacity
|
|
55
|
+
testID="select-box"
|
|
56
|
+
style={styles(styleProps).selectBox}
|
|
57
|
+
onPress={() => setModalVisible(true)}
|
|
58
|
+
>
|
|
59
|
+
<Text style={styles(styleProps).selectedText} numberOfLines={1}>
|
|
60
|
+
{`${handleLimitTextdisplayByAmount({
|
|
61
|
+
limit: 42,
|
|
62
|
+
text: dataOption.find((item) => item.value === selectedValue)?.label!,
|
|
63
|
+
})}`}
|
|
64
|
+
</Text>
|
|
65
|
+
|
|
66
|
+
<Icons
|
|
67
|
+
size={theme.fontSizes["xs"]}
|
|
68
|
+
color={theme.colors.blue[500]}
|
|
69
|
+
icon={"ARROW_DROP_DOWN"}
|
|
70
|
+
/>
|
|
71
|
+
</TouchableOpacity>
|
|
72
|
+
|
|
73
|
+
{/* Modal para exibir as opções */}
|
|
74
|
+
<Modal testID="modal-container" visible={modalVisible} transparent animationType="fade">
|
|
75
|
+
<View style={styles(styleProps).modalOverlay}>
|
|
76
|
+
<View style={styles(styleProps).modalContainer}>
|
|
77
|
+
<View
|
|
78
|
+
style={{
|
|
79
|
+
width: "100%",
|
|
80
|
+
alignItems: "flex-end",
|
|
81
|
+
height: 40,
|
|
82
|
+
paddingRight: 8,
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
<TouchableOpacity
|
|
86
|
+
testID="close-icon"
|
|
87
|
+
onPress={() => setModalVisible(false)}
|
|
88
|
+
style={{
|
|
89
|
+
width: 40,
|
|
90
|
+
height: 45,
|
|
91
|
+
alignItems: "center",
|
|
92
|
+
justifyContent: "center",
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
<Icons
|
|
96
|
+
size={theme.fontSizes["md"]}
|
|
97
|
+
color={theme.colors.blue[500]}
|
|
98
|
+
icon={"CLOSED"}
|
|
99
|
+
/>
|
|
100
|
+
</TouchableOpacity>
|
|
101
|
+
</View>
|
|
102
|
+
<FlatList
|
|
103
|
+
data={dataOption || []}
|
|
104
|
+
keyExtractor={(item) => item.value}
|
|
105
|
+
renderItem={({ item }) => (
|
|
106
|
+
<TouchableOpacity
|
|
107
|
+
style={styles(styleProps).option}
|
|
108
|
+
onPress={() => handleSelect(item.value)}
|
|
109
|
+
>
|
|
110
|
+
<Text style={styles(styleProps).optionText}>{item.label}</Text>
|
|
111
|
+
</TouchableOpacity>
|
|
112
|
+
)}
|
|
113
|
+
/>
|
|
114
|
+
</View>
|
|
115
|
+
</View>
|
|
116
|
+
</Modal>
|
|
117
|
+
</View>
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Componente SelectOption para a interação da ui.
|
|
123
|
+
*/
|
|
124
|
+
export default asBaseComponent(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
|
-
backgroundColor?: string;
|
|
10
|
-
/**retorna o valor selecionado */
|
|
11
|
-
// eslint-disable-next-line no-unused-vars
|
|
12
|
-
handleSelectDown: (value:
|
|
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: number) => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* EXPORTS
|
|
17
|
+
*/
|
|
18
|
+
export { ISelectDropDownProps };
|