react-native-exp-fig 0.1.24 → 0.1.26
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/image-capture-with-remove/index.js +2 -1
- package/lib/commonjs/components/image-capture-with-remove/index.js.map +1 -1
- package/lib/commonjs/components/image-capture-with-remove/interface.d.js.map +1 -1
- package/lib/commonjs/components/modal-change-activity/index.js.map +1 -1
- package/lib/commonjs/components/step-indicator/index.js +71 -60
- package/lib/commonjs/components/step-indicator/index.js.map +1 -1
- package/lib/commonjs/components/step-indicator/interface.d.js.map +1 -1
- package/lib/commonjs/components/step-indicator/styles.js +8 -10
- package/lib/commonjs/components/step-indicator/styles.js.map +1 -1
- package/lib/commonjs/index.js +2 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/stories/modal-change-activity/modal-change-activity.stories.js +0 -2
- package/lib/commonjs/stories/modal-change-activity/modal-change-activity.stories.js.map +1 -1
- package/lib/commonjs/stories/step-indicator/step-indicator.stories.js +14 -7
- package/lib/commonjs/stories/step-indicator/step-indicator.stories.js.map +1 -1
- package/lib/commonjs/utils/format-date/index.js +54 -0
- package/lib/commonjs/utils/format-date/index.js.map +1 -0
- package/lib/module/components/image-capture-with-remove/index.js +2 -1
- package/lib/module/components/image-capture-with-remove/index.js.map +1 -1
- package/lib/module/components/image-capture-with-remove/interface.d.js.map +1 -1
- package/lib/module/components/modal-change-activity/index.js.map +1 -1
- package/lib/module/components/step-indicator/index.js +71 -60
- package/lib/module/components/step-indicator/index.js.map +1 -1
- package/lib/module/components/step-indicator/interface.d.js.map +1 -1
- package/lib/module/components/step-indicator/styles.js +8 -10
- package/lib/module/components/step-indicator/styles.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/stories/modal-change-activity/modal-change-activity.stories.js +0 -2
- package/lib/module/stories/modal-change-activity/modal-change-activity.stories.js.map +1 -1
- package/lib/module/stories/step-indicator/step-indicator.stories.js +12 -6
- package/lib/module/stories/step-indicator/step-indicator.stories.js.map +1 -1
- package/lib/module/utils/format-date/index.js +50 -0
- package/lib/module/utils/format-date/index.js.map +1 -0
- package/lib/typescript/src/components/modal-change-activity/index.d.ts +0 -2
- package/lib/typescript/src/components/step-indicator/index.d.ts +2 -2
- package/lib/typescript/src/components/step-indicator/styles.d.ts +2 -3
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/stories/step-indicator/step-indicator.stories.d.ts +1 -1
- package/lib/typescript/src/utils/format-date/index.d.ts +24 -0
- package/package.json +1 -1
- package/src/components/image-capture-with-remove/index.tsx +2 -1
- package/src/components/image-capture-with-remove/interface.d.ts +2 -0
- package/src/components/modal-change-activity/index.tsx +0 -2
- package/src/components/step-indicator/index.tsx +235 -222
- package/src/components/step-indicator/interface.d.ts +47 -35
- package/src/components/step-indicator/styles.ts +66 -68
- package/src/index.ts +1 -1
- package/src/stories/modal-change-activity/modal-change-activity.stories.tsx +0 -2
- package/src/stories/step-indicator/step-indicator.stories.tsx +160 -154
- package/src/utils/format-date/index.ts +58 -0
|
@@ -1,222 +1,235 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* IMPORTS
|
|
3
|
-
*/
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { View, Text } from "react-native";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
1
|
+
/**
|
|
2
|
+
* IMPORTS
|
|
3
|
+
*/
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { View, Text, TouchableOpacity } from "react-native";
|
|
6
|
+
|
|
7
|
+
// commons / svg
|
|
8
|
+
import { Icons } from "../../common/icons-svg";
|
|
9
|
+
|
|
10
|
+
// helpers
|
|
11
|
+
import { getIconKeyByValue } from "./helpers/get-icon-by-status";
|
|
12
|
+
|
|
13
|
+
// typings
|
|
14
|
+
import type { IStepIndicator } from "./interface";
|
|
15
|
+
|
|
16
|
+
// styles
|
|
17
|
+
import { styles } from "./styles";
|
|
18
|
+
import { formHoursMinute } from "../../utils/format-data";
|
|
19
|
+
import { theme } from "../../styles/theme/theme";
|
|
20
|
+
import { ModalChangeActivity } from "../modal-change-activity";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Componente StepIndicator para a interação da ui.
|
|
24
|
+
*/
|
|
25
|
+
const StepIndicator: React.FC<IStepIndicator> = ({
|
|
26
|
+
data = [],
|
|
27
|
+
type,
|
|
28
|
+
textColorDescription,
|
|
29
|
+
titleColor,
|
|
30
|
+
titleNumberColor,
|
|
31
|
+
onChangeActivity,
|
|
32
|
+
}) => {
|
|
33
|
+
const StepDefault = () => {
|
|
34
|
+
const [isModalVisible, setIsModalVisible] = React.useState(false);
|
|
35
|
+
const [currentStepIndex, setCurrentStepIndex] = React.useState<number | null>(null);
|
|
36
|
+
const [stepData, setStepData] = React.useState(data);
|
|
37
|
+
|
|
38
|
+
const handleOnPressActivitie = (stepItem: any, index: number) => {
|
|
39
|
+
const desc = stepItem?.descricao?.toLowerCase?.();
|
|
40
|
+
if (!desc) return;
|
|
41
|
+
|
|
42
|
+
const isDescanso = ["descanso", "refeição", "repouso_noturno", "repouso_semanal"].includes(
|
|
43
|
+
desc.replace(/\s+/g, "_")
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
if (isDescanso && stepItem?.sincronizado === true) {
|
|
47
|
+
setCurrentStepIndex(index);
|
|
48
|
+
setIsModalVisible(true);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleConfirmModal = (newData: { label: string; value: string; key: number }) => {
|
|
53
|
+
if (currentStepIndex !== null) {
|
|
54
|
+
const updatedStep = {
|
|
55
|
+
...stepData[currentStepIndex],
|
|
56
|
+
descricao: newData.label,
|
|
57
|
+
referencia: newData.value,
|
|
58
|
+
ec_tipo_atividade_id: newData.key,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const newSteps = stepData.map((item, index) =>
|
|
62
|
+
index === currentStepIndex ? updatedStep : item
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
setStepData(newSteps as any);
|
|
66
|
+
|
|
67
|
+
if (onChangeActivity) {
|
|
68
|
+
onChangeActivity(updatedStep);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
setIsModalVisible(false);
|
|
73
|
+
setCurrentStepIndex(null);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<>
|
|
78
|
+
{stepData.length > 0 &&
|
|
79
|
+
stepData.map((history, index) => {
|
|
80
|
+
const isFirst = index === 0;
|
|
81
|
+
const isEditableType = history.tipo === "descanso";
|
|
82
|
+
const isSynced = history?.sincronizado === true;
|
|
83
|
+
const canEdit = isFirst && isEditableType && isSynced;
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<TouchableOpacity
|
|
87
|
+
testID="step-indicator"
|
|
88
|
+
activeOpacity={0.7}
|
|
89
|
+
key={history?.id}
|
|
90
|
+
style={styles({}).containerIndicator}
|
|
91
|
+
disabled={!canEdit}
|
|
92
|
+
onPress={() => handleOnPressActivitie(history, index)}
|
|
93
|
+
>
|
|
94
|
+
<View style={styles({ sincronizado: history.sincronizado }).containerBall}>
|
|
95
|
+
{stepData.length > 1 && index < stepData.length - 1 && (
|
|
96
|
+
<View
|
|
97
|
+
style={{
|
|
98
|
+
width: 2,
|
|
99
|
+
height: 84,
|
|
100
|
+
marginTop: 116,
|
|
101
|
+
position: "relative",
|
|
102
|
+
backgroundColor: history.sincronizado
|
|
103
|
+
? theme.colors.blue[500]
|
|
104
|
+
: theme.colors.orange[150],
|
|
105
|
+
}}
|
|
106
|
+
/>
|
|
107
|
+
)}
|
|
108
|
+
<Text style={styles({ titleNumberColor }).titleNumber}>
|
|
109
|
+
{stepData.length - index}
|
|
110
|
+
</Text>
|
|
111
|
+
</View>
|
|
112
|
+
|
|
113
|
+
<View style={styles({}).containerMain}>
|
|
114
|
+
<Text style={styles({ titleColor }).title}>{history?.descricao}</Text>
|
|
115
|
+
|
|
116
|
+
{history?.data_inicio && (
|
|
117
|
+
<Text style={styles({ textColorDescription }).titleDescription}>
|
|
118
|
+
{`Inicio: ${history.data_inicio} ás ${history.data_fim}`}
|
|
119
|
+
</Text>
|
|
120
|
+
)}
|
|
121
|
+
|
|
122
|
+
{history.duracao_segundos && (
|
|
123
|
+
<Text style={styles({ textColorDescription }).titleDescription}>
|
|
124
|
+
Duração: {formHoursMinute(history?.duracao_segundos as string)}
|
|
125
|
+
</Text>
|
|
126
|
+
)}
|
|
127
|
+
</View>
|
|
128
|
+
</TouchableOpacity>
|
|
129
|
+
);
|
|
130
|
+
})}
|
|
131
|
+
|
|
132
|
+
{isModalVisible && (
|
|
133
|
+
<ModalChangeActivity
|
|
134
|
+
visible={isModalVisible}
|
|
135
|
+
modalConfirm={handleConfirmModal}
|
|
136
|
+
descricao=""
|
|
137
|
+
onClose={() => setIsModalVisible(false)}
|
|
138
|
+
/>
|
|
139
|
+
)}
|
|
140
|
+
</>
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const StepCustom = () => {
|
|
145
|
+
return (
|
|
146
|
+
<View
|
|
147
|
+
style={{
|
|
148
|
+
width: "100%",
|
|
149
|
+
height: 84,
|
|
150
|
+
paddingHorizontal: 24,
|
|
151
|
+
display: "flex",
|
|
152
|
+
flexDirection: "row",
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
{data.map((step, indexCustom) => {
|
|
156
|
+
const descricao = getIconKeyByValue(step.descricao);
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<React.Fragment key={`step-${indexCustom}`}>
|
|
160
|
+
<View
|
|
161
|
+
style={{
|
|
162
|
+
width: 45,
|
|
163
|
+
height: 45,
|
|
164
|
+
backgroundColor: indexCustom <= 3 ? "orange" : "transparent",
|
|
165
|
+
borderRadius: 50,
|
|
166
|
+
alignItems: "center",
|
|
167
|
+
justifyContent: "center",
|
|
168
|
+
borderWidth: 1,
|
|
169
|
+
borderColor: "#fff",
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
<View
|
|
173
|
+
style={{
|
|
174
|
+
width: 45,
|
|
175
|
+
height: 45,
|
|
176
|
+
backgroundColor: "transparent",
|
|
177
|
+
borderRadius: 50,
|
|
178
|
+
alignItems: "center",
|
|
179
|
+
justifyContent: "center",
|
|
180
|
+
}}
|
|
181
|
+
>
|
|
182
|
+
{descricao && <Icons icon={descricao} />}
|
|
183
|
+
</View>
|
|
184
|
+
<Text
|
|
185
|
+
style={{
|
|
186
|
+
position: "absolute",
|
|
187
|
+
top: 56,
|
|
188
|
+
fontWeight: "600",
|
|
189
|
+
fontSize: 10,
|
|
190
|
+
lineHeight: 14,
|
|
191
|
+
textAlign: "center",
|
|
192
|
+
color: "#fff",
|
|
193
|
+
width: 75,
|
|
194
|
+
}}
|
|
195
|
+
>
|
|
196
|
+
{step.descricao}
|
|
197
|
+
</Text>
|
|
198
|
+
</View>
|
|
199
|
+
|
|
200
|
+
{data?.length > 1 && indexCustom < data?.length - 1 && (
|
|
201
|
+
<View
|
|
202
|
+
style={{
|
|
203
|
+
width: 35,
|
|
204
|
+
height: 2,
|
|
205
|
+
marginTop: 24,
|
|
206
|
+
position: "relative",
|
|
207
|
+
backgroundColor: "orange",
|
|
208
|
+
}}
|
|
209
|
+
/>
|
|
210
|
+
)}
|
|
211
|
+
</React.Fragment>
|
|
212
|
+
);
|
|
213
|
+
})}
|
|
214
|
+
</View>
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const handleRenderComponent = (stepType: "default" | "custom") => {
|
|
219
|
+
switch (stepType) {
|
|
220
|
+
case "default":
|
|
221
|
+
return <StepDefault />;
|
|
222
|
+
case "custom":
|
|
223
|
+
return <StepCustom />;
|
|
224
|
+
default:
|
|
225
|
+
return <View />;
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
return <>{handleRenderComponent(type!)}</>;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* EXPORTS
|
|
234
|
+
*/
|
|
235
|
+
export default StepIndicator;
|
|
@@ -1,35 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
/**
|
|
3
|
+
* IMPORTS
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
type IData = {
|
|
7
|
+
id?: number | string;
|
|
8
|
+
ec_tipo_atividade_id?: number;
|
|
9
|
+
duracao_segundos: string | number;
|
|
10
|
+
data_inicio: string;
|
|
11
|
+
data_fim: string;
|
|
12
|
+
descricao: string;
|
|
13
|
+
sincronizado;
|
|
14
|
+
tipo: string;
|
|
15
|
+
referencia: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type IStyleProps = {
|
|
19
|
+
sincronizado?: boolean;
|
|
20
|
+
titleColor?: string;
|
|
21
|
+
titleNumberColor?: string;
|
|
22
|
+
textColorDescription?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
interface IStepIndicator {
|
|
26
|
+
/**dados que vão ser renderizados */
|
|
27
|
+
data?: IData[];
|
|
28
|
+
|
|
29
|
+
/**tupo de renderização padrão ou customizada */
|
|
30
|
+
type?: "default" | "custom";
|
|
31
|
+
|
|
32
|
+
/**cor do texto */
|
|
33
|
+
titleColor?: string;
|
|
34
|
+
|
|
35
|
+
/**cor do numero do step indicator */
|
|
36
|
+
titleNumberColor?: string;
|
|
37
|
+
|
|
38
|
+
/**cor do texto da descrição */
|
|
39
|
+
textColorDescription?: string;
|
|
40
|
+
|
|
41
|
+
/**params para lidar com selecionamento de atividade única */
|
|
42
|
+
onChangeActivity?: (activity: any) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* EXPORTS
|
|
46
|
+
*/
|
|
47
|
+
export { type IStepIndicator, IStyleProps };
|