react-native-exp-fig 0.1.25 → 0.1.27

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 (199) hide show
  1. package/lib/commonjs/components/input-text-counter/index.js +66 -0
  2. package/lib/commonjs/components/input-text-counter/index.js.map +1 -0
  3. package/lib/commonjs/components/input-text-counter/interface.d.js.map +1 -0
  4. package/lib/commonjs/components/input-text-counter/styles.js +42 -0
  5. package/lib/commonjs/components/input-text-counter/styles.js.map +1 -0
  6. package/lib/commonjs/components/modal-create-activitie/index.js +202 -0
  7. package/lib/commonjs/components/modal-create-activitie/index.js.map +1 -0
  8. package/lib/commonjs/components/modal-create-activitie/interface.js +2 -0
  9. package/lib/commonjs/components/modal-create-activitie/interface.js.map +1 -0
  10. package/lib/commonjs/components/modal-create-activitie/styles.js +42 -0
  11. package/lib/commonjs/components/modal-create-activitie/styles.js.map +1 -0
  12. package/lib/commonjs/components/modal-journey-rectification/index.js +202 -0
  13. package/lib/commonjs/components/modal-journey-rectification/index.js.map +1 -0
  14. package/lib/commonjs/components/modal-journey-rectification/interface.d.js +2 -0
  15. package/lib/commonjs/components/modal-journey-rectification/interface.d.js.map +1 -0
  16. package/lib/commonjs/components/modal-journey-rectification/styles.js +42 -0
  17. package/lib/commonjs/components/modal-journey-rectification/styles.js.map +1 -0
  18. package/lib/commonjs/components/{modal-activities → modals/modal-activities}/data-activities/index.js +2 -2
  19. package/lib/commonjs/components/modals/modal-activities/data-activities/index.js.map +1 -0
  20. package/lib/commonjs/components/{modal-activities → modals/modal-activities}/index.js +8 -8
  21. package/lib/commonjs/components/modals/modal-activities/index.js.map +1 -0
  22. package/lib/commonjs/components/modals/modal-activities/interface.d.js +6 -0
  23. package/lib/commonjs/components/modals/modal-activities/interface.d.js.map +1 -0
  24. package/lib/commonjs/components/modals/modal-activity-reason/index.js +161 -0
  25. package/lib/commonjs/components/modals/modal-activity-reason/index.js.map +1 -0
  26. package/lib/commonjs/components/modals/modal-activity-reason/interface.d.js +2 -0
  27. package/lib/commonjs/components/modals/modal-activity-reason/interface.d.js.map +1 -0
  28. package/lib/commonjs/components/{modal-change-activity → modals/modal-change-activity}/index.js +7 -7
  29. package/lib/commonjs/components/modals/modal-change-activity/index.js.map +1 -0
  30. package/lib/commonjs/components/selects/select-date-and-hours/index.js +95 -0
  31. package/lib/commonjs/components/selects/select-date-and-hours/index.js.map +1 -0
  32. package/lib/commonjs/components/selects/select-date-and-hours/interface.js +6 -0
  33. package/lib/commonjs/components/selects/select-date-and-hours/interface.js.map +1 -0
  34. package/lib/commonjs/components/selects/select-date-and-hours/styles.js +33 -0
  35. package/lib/commonjs/components/selects/select-date-and-hours/styles.js.map +1 -0
  36. package/lib/commonjs/components/selects/select-option/index.js +41 -39
  37. package/lib/commonjs/components/selects/select-option/index.js.map +1 -1
  38. package/lib/commonjs/components/step-indicator/index.js +10 -10
  39. package/lib/commonjs/components/step-indicator/index.js.map +1 -1
  40. package/lib/commonjs/components/step-indicator/interface.d.js.map +1 -1
  41. package/lib/commonjs/index.js +32 -4
  42. package/lib/commonjs/index.js.map +1 -1
  43. package/lib/commonjs/stories/input-text-counter/input-text-counter.stories.js +259 -0
  44. package/lib/commonjs/stories/input-text-counter/input-text-counter.stories.js.map +1 -0
  45. package/lib/commonjs/stories/modal-activities/modal-activities.stories.js +1 -1
  46. package/lib/commonjs/stories/modal-activities/modal-activities.stories.js.map +1 -1
  47. package/lib/commonjs/stories/modal-activity-reason/modal-activity-reason.stories.js +198 -0
  48. package/lib/commonjs/stories/modal-activity-reason/modal-activity-reason.stories.js.map +1 -0
  49. package/lib/commonjs/stories/modal-change-activity/modal-change-activity.stories.js +3 -3
  50. package/lib/commonjs/stories/modal-change-activity/modal-change-activity.stories.js.map +1 -1
  51. package/lib/commonjs/stories/modal-create-activitie/modal-create-activitie.stories.js +86 -0
  52. package/lib/commonjs/stories/modal-create-activitie/modal-create-activitie.stories.js.map +1 -0
  53. package/lib/commonjs/stories/modal-journey-rectification/modal-journey-rectification.stories.js +172 -0
  54. package/lib/commonjs/stories/modal-journey-rectification/modal-journey-rectification.stories.js.map +1 -0
  55. package/lib/commonjs/stories/select-option/select-option.stories.js +3 -2
  56. package/lib/commonjs/stories/select-option/select-option.stories.js.map +1 -1
  57. package/lib/commonjs/stories/step-indicator/step-indicator.stories.js +2 -1
  58. package/lib/commonjs/stories/step-indicator/step-indicator.stories.js.map +1 -1
  59. package/lib/commonjs/styles/theme/theme.js +18 -2
  60. package/lib/commonjs/styles/theme/theme.js.map +1 -1
  61. package/lib/commonjs/utils/options-activity/index.js +27 -0
  62. package/lib/commonjs/utils/options-activity/index.js.map +1 -0
  63. package/lib/commonjs/utils/text-limit/index.js +37 -0
  64. package/lib/commonjs/utils/text-limit/index.js.map +1 -0
  65. package/lib/module/components/input-text-counter/index.js +63 -0
  66. package/lib/module/components/input-text-counter/index.js.map +1 -0
  67. package/lib/module/components/input-text-counter/interface.d.js.map +1 -0
  68. package/lib/module/components/input-text-counter/styles.js +37 -0
  69. package/lib/module/components/input-text-counter/styles.js.map +1 -0
  70. package/lib/module/components/modal-create-activitie/index.js +192 -0
  71. package/lib/module/components/modal-create-activitie/index.js.map +1 -0
  72. package/lib/module/components/modal-create-activitie/interface.js +2 -0
  73. package/lib/module/components/modal-create-activitie/interface.js.map +1 -0
  74. package/lib/module/components/modal-create-activitie/styles.js +37 -0
  75. package/lib/module/components/modal-create-activitie/styles.js.map +1 -0
  76. package/lib/module/components/modal-journey-rectification/index.js +192 -0
  77. package/lib/module/components/modal-journey-rectification/index.js.map +1 -0
  78. package/lib/module/components/modal-journey-rectification/interface.d.js +2 -0
  79. package/lib/module/components/modal-journey-rectification/interface.d.js.map +1 -0
  80. package/lib/module/components/modal-journey-rectification/styles.js +37 -0
  81. package/lib/module/components/modal-journey-rectification/styles.js.map +1 -0
  82. package/lib/module/components/{modal-activities → modals/modal-activities}/data-activities/index.js +2 -2
  83. package/lib/module/components/modals/modal-activities/data-activities/index.js.map +1 -0
  84. package/lib/module/components/{modal-activities → modals/modal-activities}/index.js +8 -8
  85. package/lib/module/components/modals/modal-activities/index.js.map +1 -0
  86. package/lib/module/components/modals/modal-activities/interface.d.js +2 -0
  87. package/lib/module/components/modals/modal-activities/interface.d.js.map +1 -0
  88. package/lib/module/components/modals/modal-activity-reason/index.js +151 -0
  89. package/lib/module/components/modals/modal-activity-reason/index.js.map +1 -0
  90. package/lib/module/components/modals/modal-activity-reason/interface.d.js +2 -0
  91. package/lib/module/components/modals/modal-activity-reason/interface.d.js.map +1 -0
  92. package/lib/module/components/{modal-change-activity → modals/modal-change-activity}/index.js +6 -6
  93. package/lib/module/components/modals/modal-change-activity/index.js.map +1 -0
  94. package/lib/module/components/selects/select-date-and-hours/index.js +86 -0
  95. package/lib/module/components/selects/select-date-and-hours/index.js.map +1 -0
  96. package/lib/module/components/selects/select-date-and-hours/interface.js +2 -0
  97. package/lib/module/components/selects/select-date-and-hours/interface.js.map +1 -0
  98. package/lib/module/components/selects/select-date-and-hours/styles.js +28 -0
  99. package/lib/module/components/selects/select-date-and-hours/styles.js.map +1 -0
  100. package/lib/module/components/selects/select-option/index.js +41 -42
  101. package/lib/module/components/selects/select-option/index.js.map +1 -1
  102. package/lib/module/components/step-indicator/index.js +10 -10
  103. package/lib/module/components/step-indicator/index.js.map +1 -1
  104. package/lib/module/components/step-indicator/interface.d.js.map +1 -1
  105. package/lib/module/index.js +9 -5
  106. package/lib/module/index.js.map +1 -1
  107. package/lib/module/stories/input-text-counter/input-text-counter.stories.js +253 -0
  108. package/lib/module/stories/input-text-counter/input-text-counter.stories.js.map +1 -0
  109. package/lib/module/stories/modal-activities/modal-activities.stories.js +1 -1
  110. package/lib/module/stories/modal-activities/modal-activities.stories.js.map +1 -1
  111. package/lib/module/stories/modal-activity-reason/modal-activity-reason.stories.js +193 -0
  112. package/lib/module/stories/modal-activity-reason/modal-activity-reason.stories.js.map +1 -0
  113. package/lib/module/stories/modal-change-activity/modal-change-activity.stories.js +3 -3
  114. package/lib/module/stories/modal-change-activity/modal-change-activity.stories.js.map +1 -1
  115. package/lib/module/stories/modal-create-activitie/modal-create-activitie.stories.js +78 -0
  116. package/lib/module/stories/modal-create-activitie/modal-create-activitie.stories.js.map +1 -0
  117. package/lib/module/stories/modal-journey-rectification/modal-journey-rectification.stories.js +168 -0
  118. package/lib/module/stories/modal-journey-rectification/modal-journey-rectification.stories.js.map +1 -0
  119. package/lib/module/stories/select-option/select-option.stories.js +1 -1
  120. package/lib/module/stories/select-option/select-option.stories.js.map +1 -1
  121. package/lib/module/stories/step-indicator/step-indicator.stories.js +2 -1
  122. package/lib/module/stories/step-indicator/step-indicator.stories.js.map +1 -1
  123. package/lib/module/styles/theme/theme.js +18 -2
  124. package/lib/module/styles/theme/theme.js.map +1 -1
  125. package/lib/module/utils/options-activity/index.js +22 -0
  126. package/lib/module/utils/options-activity/index.js.map +1 -0
  127. package/lib/module/utils/text-limit/index.js +30 -0
  128. package/lib/module/utils/text-limit/index.js.map +1 -0
  129. package/lib/typescript/src/components/input-text-counter/index.d.ts +33 -0
  130. package/lib/typescript/src/components/input-text-counter/styles.d.ts +34 -0
  131. package/lib/typescript/src/components/modal-create-activitie/index.d.ts +7 -0
  132. package/lib/typescript/src/components/modal-create-activitie/interface.d.ts +18 -0
  133. package/lib/typescript/src/components/modal-create-activitie/styles.d.ts +32 -0
  134. package/lib/typescript/src/components/modal-journey-rectification/index.d.ts +7 -0
  135. package/lib/typescript/src/components/modal-journey-rectification/styles.d.ts +32 -0
  136. package/lib/typescript/src/components/modals/modal-activity-reason/index.d.ts +7 -0
  137. package/lib/typescript/src/components/selects/select-date-and-hours/index.d.ts +12 -0
  138. package/lib/typescript/src/components/selects/select-date-and-hours/interface.d.ts +21 -0
  139. package/lib/typescript/src/components/selects/select-date-and-hours/styles.d.ts +24 -0
  140. package/lib/typescript/src/components/selects/select-option/index.d.ts +3 -6
  141. package/lib/typescript/src/index.d.ts +7 -3
  142. package/lib/typescript/src/stories/input-text-counter/input-text-counter.stories.d.ts +17 -0
  143. package/lib/typescript/src/stories/modal-activities/modal-activities.stories.d.ts +1 -1
  144. package/lib/typescript/src/stories/modal-activity-reason/modal-activity-reason.stories.d.ts +15 -0
  145. package/lib/typescript/src/stories/modal-change-activity/modal-change-activity.stories.d.ts +1 -1
  146. package/lib/typescript/src/stories/modal-create-activitie/modal-create-activitie.stories.d.ts +12 -0
  147. package/lib/typescript/src/stories/modal-journey-rectification/modal-journey-rectification.stories.d.ts +34 -0
  148. package/lib/typescript/src/stories/select-option/select-option.stories.d.ts +1 -1
  149. package/lib/typescript/src/styles/global/theme-provider.d.ts +16 -0
  150. package/lib/typescript/src/styles/theme/theme.d.ts +16 -0
  151. package/lib/typescript/src/utils/options-activity/index.d.ts +20 -0
  152. package/lib/typescript/src/utils/text-limit/index.d.ts +13 -0
  153. package/package.json +1 -1
  154. package/src/components/input-text-counter/index.tsx +64 -0
  155. package/src/components/input-text-counter/interface.d.ts +41 -0
  156. package/src/components/input-text-counter/styles.ts +38 -0
  157. package/src/components/modal-create-activitie/index.tsx +211 -0
  158. package/src/components/modal-create-activitie/interface.ts +22 -0
  159. package/src/components/modal-create-activitie/styles.ts +24 -0
  160. package/src/components/modal-journey-rectification/index.tsx +211 -0
  161. package/src/components/modal-journey-rectification/interface.d.ts +22 -0
  162. package/src/components/modal-journey-rectification/styles.ts +24 -0
  163. package/src/components/{modal-activities → modals/modal-activities}/data-activities/index.ts +65 -65
  164. package/src/components/{modal-activities → modals/modal-activities}/index.tsx +137 -137
  165. package/src/components/{modal-activities → modals/modal-activities}/interface.d.ts +32 -32
  166. package/src/components/modals/modal-activity-reason/index.tsx +162 -0
  167. package/src/components/modals/modal-activity-reason/interface.d.ts +10 -0
  168. package/src/components/{modal-change-activity → modals/modal-change-activity}/index.tsx +6 -6
  169. package/src/components/selects/select-date-and-hours/index.tsx +97 -0
  170. package/src/components/selects/select-date-and-hours/interface.ts +31 -0
  171. package/src/components/selects/select-date-and-hours/styles.ts +24 -0
  172. package/src/components/selects/select-option/index.tsx +50 -41
  173. package/src/components/step-indicator/index.tsx +235 -235
  174. package/src/components/step-indicator/interface.d.ts +2 -2
  175. package/src/index.ts +49 -45
  176. package/src/stories/input-text-counter/input-text-counter.stories.tsx +232 -0
  177. package/src/stories/modal-activities/modal-activities.stories.tsx +64 -64
  178. package/src/stories/modal-activity-reason/modal-activity-reason.stories.tsx +192 -0
  179. package/src/stories/modal-change-activity/modal-change-activity.stories.tsx +49 -49
  180. package/src/stories/modal-create-activitie/modal-create-activitie.stories.tsx +82 -0
  181. package/src/stories/modal-journey-rectification/modal-journey-rectification.stories.tsx +161 -0
  182. package/src/stories/select-option/select-option.stories.tsx +1 -1
  183. package/src/stories/step-indicator/step-indicator.stories.tsx +2 -1
  184. package/src/styles/theme/theme.ts +17 -0
  185. package/src/utils/options-activity/index.ts +14 -0
  186. package/src/utils/text-limit/index.ts +28 -0
  187. package/lib/commonjs/components/modal-activities/data-activities/index.js.map +0 -1
  188. package/lib/commonjs/components/modal-activities/index.js.map +0 -1
  189. package/lib/commonjs/components/modal-activities/interface.d.js.map +0 -1
  190. package/lib/commonjs/components/modal-change-activity/index.js.map +0 -1
  191. package/lib/module/components/modal-activities/data-activities/index.js.map +0 -1
  192. package/lib/module/components/modal-activities/index.js.map +0 -1
  193. package/lib/module/components/modal-activities/interface.d.js.map +0 -1
  194. package/lib/module/components/modal-change-activity/index.js.map +0 -1
  195. /package/lib/commonjs/components/{modal-activities → input-text-counter}/interface.d.js +0 -0
  196. /package/lib/module/components/{modal-activities → input-text-counter}/interface.d.js +0 -0
  197. /package/lib/typescript/src/components/{modal-activities → modals/modal-activities}/data-activities/index.d.ts +0 -0
  198. /package/lib/typescript/src/components/{modal-activities → modals/modal-activities}/index.d.ts +0 -0
  199. /package/lib/typescript/src/components/{modal-change-activity → modals/modal-change-activity}/index.d.ts +0 -0
@@ -0,0 +1,24 @@
1
+ /**
2
+ * IMPORTS
3
+ */
4
+
5
+ import { StyleSheet } from "react-native";
6
+
7
+ const styles = StyleSheet.create({
8
+ field: {
9
+ width: "100%",
10
+ height: 45,
11
+ borderRadius: 12,
12
+ borderWidth: 1,
13
+ paddingHorizontal: 12,
14
+ justifyContent: "center",
15
+ marginTop: 10,
16
+ marginBottom: 16,
17
+ },
18
+ row: { flexDirection: "row", alignItems: "center", justifyContent: "space-around" },
19
+ });
20
+
21
+ /**
22
+ * EXPORTS
23
+ */
24
+ export { styles };
@@ -1,29 +1,33 @@
1
1
  /**
2
2
  * IMPORTS
3
3
  */
4
- import React from "react";
5
- import { useState } from "react";
4
+ import React, { forwardRef, useState } from "react";
6
5
  import { View, Text, TouchableOpacity, Modal, FlatList } from "react-native";
7
6
 
7
+ // commons / svg
8
+ import { Icons } from "../../../common/icons-svg";
9
+
10
+ // utils
11
+ import { handleLimitTextdisplayByAmount } from "../../../utils/text-limit";
12
+
8
13
  // typings
9
- import { ISelectDropDownProps } from "./interface";
14
+ import { asBaseComponent } from "../../../@types/as-base-component";
15
+ import type { ISelectDropDownProps } from "./interface";
10
16
 
11
17
  // styles
12
18
  import { styles } from "./styles";
13
- import { Icons } from "../../../common/icons-svg";
14
19
  import { theme } from "../../../styles/theme/theme";
15
20
 
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) => {
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
+
27
31
  const [selectedValue, setSelectedValue] = useState(dataOption[0]?.value || "");
28
32
  const [modalVisible, setModalVisible] = useState(false);
29
33
 
@@ -41,24 +45,26 @@ const SelectOption: React.FC<ISelectDropDownProps> = ({
41
45
  colortitleLabel,
42
46
  backgroundColor,
43
47
  } as ISelectDropDownProps;
44
-
45
48
  return (
46
- <View style={styles(styleProps).container}>
49
+ <View ref={ref} style={styles(styleProps).container}>
47
50
  {/* Titulo para exibir o label */}
48
51
  <Text style={styles(styleProps).label}>{`${titleLabel ?? "Selecione uma opção"}`}:</Text>
49
52
 
50
53
  {/* Botão para abrir o modal */}
51
54
  <TouchableOpacity
52
55
  testID="select-box"
53
- style={[styles(styleProps).selectBox, backgroundColor && { backgroundColor },]}
56
+ style={styles(styleProps).selectBox}
54
57
  onPress={() => setModalVisible(true)}
55
58
  >
56
- <Text style={styles(styleProps).selectedText}>
57
- {dataOption.find((item) => item.value === selectedValue)?.label}
59
+ <Text style={styles(styleProps).selectedText} numberOfLines={1}>
60
+ {`${handleLimitTextdisplayByAmount({
61
+ limit: 42,
62
+ text: dataOption.find((item) => item.value === selectedValue)?.label!,
63
+ })}`}
58
64
  </Text>
59
65
 
60
66
  <Icons
61
- size={theme.fontSizes["md"]}
67
+ size={theme.fontSizes["xs"]}
62
68
  color={theme.colors.blue[500]}
63
69
  icon={"ARROW_DROP_DOWN"}
64
70
  />
@@ -67,15 +73,25 @@ const SelectOption: React.FC<ISelectDropDownProps> = ({
67
73
  {/* Modal para exibir as opções */}
68
74
  <Modal testID="modal-container" visible={modalVisible} transparent animationType="fade">
69
75
  <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)}>
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
+ >
79
95
  <Icons
80
96
  size={theme.fontSizes["md"]}
81
97
  color={theme.colors.blue[500]}
@@ -88,14 +104,7 @@ const SelectOption: React.FC<ISelectDropDownProps> = ({
88
104
  keyExtractor={(item) => item.value}
89
105
  renderItem={({ item }) => (
90
106
  <TouchableOpacity
91
- style={{
92
- width: "100%",
93
- paddingVertical: 12,
94
- paddingHorizontal: 8,
95
- alignItems: "flex-start",
96
- borderBottomWidth: 1,
97
- borderColor: "#eee",
98
- }}
107
+ style={styles(styleProps).option}
99
108
  onPress={() => handleSelect(item.value)}
100
109
  >
101
110
  <Text style={styles(styleProps).optionText}>{item.label}</Text>
@@ -107,9 +116,9 @@ const SelectOption: React.FC<ISelectDropDownProps> = ({
107
116
  </Modal>
108
117
  </View>
109
118
  );
110
- };
119
+ });
111
120
 
112
121
  /**
113
- * EXPORTS
122
+ * Componente SelectOption para a interação da ui.
114
123
  */
115
- export { SelectOption };
124
+ export default asBaseComponent(SelectOption);
@@ -1,235 +1,235 @@
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
- tipo_atividade: newData.value,
58
- identificador: 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.jr_tipo_atividade_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
+ /**
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 "../modals/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;
@@ -4,8 +4,8 @@
4
4
  */
5
5
 
6
6
  type IData = {
7
- id?: number;
8
- jr_tipo_atividade_id?: number;
7
+ id?: number | string;
8
+ ec_tipo_atividade_id?: number;
9
9
  duracao_segundos: string | number;
10
10
  data_inicio: string;
11
11
  data_fim: string;