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