jornada-ui 0.4.4 → 0.4.5

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 (76) hide show
  1. package/lib/commonjs/components/resume-raking/index.js +79 -0
  2. package/lib/commonjs/components/resume-raking/index.js.map +1 -0
  3. package/lib/commonjs/components/resume-raking/interface.js +2 -0
  4. package/lib/commonjs/components/resume-raking/interface.js.map +1 -0
  5. package/lib/commonjs/components/resume-raking/styles.js +2 -0
  6. package/lib/commonjs/components/resume-raking/styles.js.map +1 -0
  7. package/lib/commonjs/components/travel-history/index.js +248 -237
  8. package/lib/commonjs/components/travel-history/index.js.map +1 -1
  9. package/lib/commonjs/components/weekly-table/helpers/calcular-total-horas.js +48 -10
  10. package/lib/commonjs/components/weekly-table/helpers/calcular-total-horas.js.map +1 -1
  11. package/lib/commonjs/components/weekly-table/index.js +6 -10
  12. package/lib/commonjs/components/weekly-table/index.js.map +1 -1
  13. package/lib/commonjs/index.js +11 -4
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/styles/theme/theme.js +1 -0
  16. package/lib/commonjs/styles/theme/theme.js.map +1 -1
  17. package/lib/module/components/resume-raking/index.js +72 -0
  18. package/lib/module/components/resume-raking/index.js.map +1 -0
  19. package/lib/module/components/resume-raking/interface.js +2 -0
  20. package/lib/module/components/resume-raking/interface.js.map +1 -0
  21. package/lib/module/components/resume-raking/styles.js +2 -0
  22. package/lib/module/components/resume-raking/styles.js.map +1 -0
  23. package/lib/module/components/travel-history/index.js +248 -237
  24. package/lib/module/components/travel-history/index.js.map +1 -1
  25. package/lib/module/components/weekly-table/helpers/calcular-total-horas.js +46 -9
  26. package/lib/module/components/weekly-table/helpers/calcular-total-horas.js.map +1 -1
  27. package/lib/module/components/weekly-table/index.js +7 -11
  28. package/lib/module/components/weekly-table/index.js.map +1 -1
  29. package/lib/module/index.js +1 -0
  30. package/lib/module/index.js.map +1 -1
  31. package/lib/module/styles/theme/theme.js +1 -0
  32. package/lib/module/styles/theme/theme.js.map +1 -1
  33. package/lib/typescript/commonjs/src/components/resume-raking/index.d.ts +8 -0
  34. package/lib/typescript/commonjs/src/components/resume-raking/index.d.ts.map +1 -0
  35. package/lib/typescript/commonjs/src/components/resume-raking/interface.d.ts +13 -0
  36. package/lib/typescript/commonjs/src/components/resume-raking/interface.d.ts.map +1 -0
  37. package/lib/typescript/commonjs/src/components/resume-raking/styles.d.ts +1 -0
  38. package/lib/typescript/commonjs/src/components/resume-raking/styles.d.ts.map +1 -0
  39. package/lib/typescript/commonjs/src/components/travel-history/index.d.ts +1 -0
  40. package/lib/typescript/commonjs/src/components/travel-history/index.d.ts.map +1 -1
  41. package/lib/typescript/commonjs/src/components/weekly-table/helpers/calcular-total-horas.d.ts +2 -1
  42. package/lib/typescript/commonjs/src/components/weekly-table/helpers/calcular-total-horas.d.ts.map +1 -1
  43. package/lib/typescript/commonjs/src/components/weekly-table/index.d.ts.map +1 -1
  44. package/lib/typescript/commonjs/src/index.d.ts +1 -0
  45. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  46. package/lib/typescript/commonjs/src/styles/global/theme-provider.d.ts +1 -0
  47. package/lib/typescript/commonjs/src/styles/global/theme-provider.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/src/styles/theme/theme.d.ts +1 -0
  49. package/lib/typescript/commonjs/src/styles/theme/theme.d.ts.map +1 -1
  50. package/lib/typescript/module/src/components/resume-raking/index.d.ts +8 -0
  51. package/lib/typescript/module/src/components/resume-raking/index.d.ts.map +1 -0
  52. package/lib/typescript/module/src/components/resume-raking/interface.d.ts +13 -0
  53. package/lib/typescript/module/src/components/resume-raking/interface.d.ts.map +1 -0
  54. package/lib/typescript/module/src/components/resume-raking/styles.d.ts +1 -0
  55. package/lib/typescript/module/src/components/resume-raking/styles.d.ts.map +1 -0
  56. package/lib/typescript/module/src/components/travel-history/index.d.ts +1 -0
  57. package/lib/typescript/module/src/components/travel-history/index.d.ts.map +1 -1
  58. package/lib/typescript/module/src/components/weekly-table/helpers/calcular-total-horas.d.ts +2 -1
  59. package/lib/typescript/module/src/components/weekly-table/helpers/calcular-total-horas.d.ts.map +1 -1
  60. package/lib/typescript/module/src/components/weekly-table/index.d.ts.map +1 -1
  61. package/lib/typescript/module/src/index.d.ts +1 -0
  62. package/lib/typescript/module/src/index.d.ts.map +1 -1
  63. package/lib/typescript/module/src/styles/global/theme-provider.d.ts +1 -0
  64. package/lib/typescript/module/src/styles/global/theme-provider.d.ts.map +1 -1
  65. package/lib/typescript/module/src/styles/theme/theme.d.ts +1 -0
  66. package/lib/typescript/module/src/styles/theme/theme.d.ts.map +1 -1
  67. package/package.json +1 -1
  68. package/src/components/resume-raking/index.tsx +75 -0
  69. package/src/components/resume-raking/interface.ts +14 -0
  70. package/src/components/resume-raking/styles.ts +0 -0
  71. package/src/components/travel-history/index.tsx +330 -314
  72. package/src/components/travel-history/interface.d.ts +153 -149
  73. package/src/components/weekly-table/helpers/calcular-total-horas.ts +89 -50
  74. package/src/components/weekly-table/index.tsx +138 -142
  75. package/src/index.tsx +1 -0
  76. package/src/styles/theme/theme.ts +1 -0
@@ -1,149 +1,153 @@
1
- /**
2
- * IMPORTS
3
- */
4
- import { type DimensionValue, type ViewProps } from "react-native";
5
-
6
- /**
7
- * INTERFACE
8
- */
9
-
10
- type ITravelHistory = ViewProps & {
11
- /**
12
- * props que mostra o nome do usuário
13
- */
14
- name?: string;
15
-
16
- /** Problemas com abastecimento (true = mostra ícone) */
17
- supplyIssue?: boolean;
18
-
19
- /** Problemas de logística (true = mostra ícone) */
20
- logisticsIssue?: boolean;
21
-
22
- /**
23
- * props que mostra o ciclo do relatório - DIÁRIA OU SEMANAL
24
- */
25
- ciclo?: string;
26
-
27
- /**
28
- * props para compor informações do card
29
- */
30
- idViagem?: string;
31
- plate?: string;
32
- value?: string;
33
- status?: string;
34
- supply?: string;
35
- nextTrip?: string;
36
- avatar?: string;
37
- startTrip?: string;
38
- origin?: string;
39
- destination?: string;
40
- /**
41
- * TestID para testes automático e identificação
42
- */
43
- testID?: string;
44
-
45
- /**
46
- * 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.
47
- */
48
- borderStyled?: {
49
- borderStyle?: "solid" | "dotted" | "dashed";
50
-
51
- borderRadius?: number | DimensionValue;
52
- borderTopRightRadius?: number | DimensionValue;
53
- borderTopLeftRadius?: number | DimensionValue;
54
- borderBottomRightRadius?: number | DimensionValue;
55
- borderBottomLeftRadius?: number | DimensionValue;
56
-
57
- borderWidth?: number | DimensionValue;
58
- borderLeftWidth?: number | DimensionValue;
59
- borderRightWidth?: number | DimensionValue;
60
- borderTopWidth?: number | DimensionValue;
61
- borderBottomWidth?: number | DimensionValue;
62
-
63
- borderColor?: string;
64
- borderBottomColor?: string;
65
- borderLeftColor?: string;
66
- borderRightColor?: string;
67
- borderTopColor?: string;
68
- };
69
-
70
- /**
71
- * 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.
72
- */
73
- flexStyle?: {
74
- alignItems?: "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
75
- alignSelf?: "auto" | "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
76
- flex?: string | number;
77
- flexDirection?: "column" | "column-reverse" | "row" | "row-reverse";
78
- flexWrap?: "nowrap" | "wrap" | "wrap-reverse";
79
- textAlign?: "auto" | "center" | "left" | "right" | "justify";
80
- justifyContent?:
81
- | "flex-start"
82
- | "flex-end"
83
- | "center"
84
- | "space-between"
85
- | "space-around"
86
- | "space-evenly";
87
- };
88
-
89
- /**
90
- * 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).
91
- */
92
- marginStyle?: {
93
- margin?: number | DimensionValue;
94
- marginLeft?: number | DimensionValue;
95
- marginRight?: number | DimensionValue;
96
- marginTop?: number | DimensionValue;
97
- marginBottom?: number | DimensionValue;
98
- };
99
-
100
- /**
101
- * 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).
102
- */
103
- paddingStyle?: {
104
- padding?: number | DimensionValue;
105
- paddingLeft?: number | DimensionValue;
106
- paddingRight?: number | DimensionValue;
107
- paddingTop?: number | DimensionValue;
108
- paddingBottom?: number | DimensionValue;
109
- };
110
-
111
- /**
112
- * 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.
113
- */
114
- height?: number | DimensionValue;
115
-
116
- /**
117
- * 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.
118
- */
119
- width?: number | DimensionValue;
120
-
121
- /**
122
- * 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..
123
- * A Propriedade Background está sendo utilizada para definir a cor de fundo do cabeçalho do card e do ícone check.
124
- */
125
- backgroundColor?: string;
126
-
127
- /**
128
- * Propriedade texto que sera renderizado pro usuário final
129
- */
130
- text?: string;
131
-
132
- /**
133
- * 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.
134
- */
135
- color?: {
136
- colorSvg?: string;
137
- colorText?: string;
138
- colorTextBold?: string;
139
- colorTextData?: string;
140
- };
141
-
142
- // Cor do ícone
143
- iconColor?: string;
144
- };
145
-
146
- /**
147
- * EXPORT
148
- */
149
- export type { ITravelHistory };
1
+ /* eslint-disable no-unused-vars */
2
+ /* eslint-disable no-undef */
3
+ /**
4
+ * IMPORTS
5
+ */
6
+ import { type DimensionValue, type ViewProps } from "react-native";
7
+
8
+ /**
9
+ * INTERFACE
10
+ */
11
+
12
+ type ITravelHistory = ViewProps & {
13
+ /** callback tipada que recebe o payload */
14
+ onPress: (tripData: T) => void;
15
+ /**
16
+ * props que mostra o nome do usuário
17
+ */
18
+ name?: string;
19
+
20
+ /** Problemas com abastecimento (true = mostra ícone) */
21
+ supplyIssue?: boolean;
22
+
23
+ /** Problemas de logística (true = mostra ícone) */
24
+ logisticsIssue?: boolean;
25
+
26
+ /**
27
+ * props que mostra o ciclo do relatório - DIÁRIA OU SEMANAL
28
+ */
29
+ ciclo?: string;
30
+
31
+ /**
32
+ * props para compor informações do card
33
+ */
34
+ idViagem?: string;
35
+ plate?: string;
36
+ value?: string;
37
+ status?: string;
38
+ supply?: string;
39
+ nextTrip?: string;
40
+ avatar?: string;
41
+ startTrip?: string;
42
+ origin?: string;
43
+ destination?: string;
44
+ /**
45
+ * TestID para testes automático e identificação
46
+ */
47
+ testID?: string;
48
+
49
+ /**
50
+ * 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.
51
+ */
52
+ borderStyled?: {
53
+ borderStyle?: "solid" | "dotted" | "dashed";
54
+
55
+ borderRadius?: number | DimensionValue;
56
+ borderTopRightRadius?: number | DimensionValue;
57
+ borderTopLeftRadius?: number | DimensionValue;
58
+ borderBottomRightRadius?: number | DimensionValue;
59
+ borderBottomLeftRadius?: number | DimensionValue;
60
+
61
+ borderWidth?: number | DimensionValue;
62
+ borderLeftWidth?: number | DimensionValue;
63
+ borderRightWidth?: number | DimensionValue;
64
+ borderTopWidth?: number | DimensionValue;
65
+ borderBottomWidth?: number | DimensionValue;
66
+
67
+ borderColor?: string;
68
+ borderBottomColor?: string;
69
+ borderLeftColor?: string;
70
+ borderRightColor?: string;
71
+ borderTopColor?: string;
72
+ };
73
+
74
+ /**
75
+ * 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.
76
+ */
77
+ flexStyle?: {
78
+ alignItems?: "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
79
+ alignSelf?: "auto" | "flex-start" | "flex-end" | "center" | "stretch" | "baseline";
80
+ flex?: string | number;
81
+ flexDirection?: "column" | "column-reverse" | "row" | "row-reverse";
82
+ flexWrap?: "nowrap" | "wrap" | "wrap-reverse";
83
+ textAlign?: "auto" | "center" | "left" | "right" | "justify";
84
+ justifyContent?:
85
+ | "flex-start"
86
+ | "flex-end"
87
+ | "center"
88
+ | "space-between"
89
+ | "space-around"
90
+ | "space-evenly";
91
+ };
92
+
93
+ /**
94
+ * 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).
95
+ */
96
+ marginStyle?: {
97
+ margin?: number | DimensionValue;
98
+ marginLeft?: number | DimensionValue;
99
+ marginRight?: number | DimensionValue;
100
+ marginTop?: number | DimensionValue;
101
+ marginBottom?: number | DimensionValue;
102
+ };
103
+
104
+ /**
105
+ * 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).
106
+ */
107
+ paddingStyle?: {
108
+ padding?: number | DimensionValue;
109
+ paddingLeft?: number | DimensionValue;
110
+ paddingRight?: number | DimensionValue;
111
+ paddingTop?: number | DimensionValue;
112
+ paddingBottom?: number | DimensionValue;
113
+ };
114
+
115
+ /**
116
+ * 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.
117
+ */
118
+ height?: number | DimensionValue;
119
+
120
+ /**
121
+ * 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.
122
+ */
123
+ width?: number | DimensionValue;
124
+
125
+ /**
126
+ * 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..
127
+ * A Propriedade Background está sendo utilizada para definir a cor de fundo do cabeçalho do card e do ícone check.
128
+ */
129
+ backgroundColor?: string;
130
+
131
+ /**
132
+ * Propriedade texto que sera renderizado pro usuário final
133
+ */
134
+ text?: string;
135
+
136
+ /**
137
+ * 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.
138
+ */
139
+ color?: {
140
+ colorSvg?: string;
141
+ colorText?: string;
142
+ colorTextBold?: string;
143
+ colorTextData?: string;
144
+ };
145
+
146
+ // Cor do ícone
147
+ iconColor?: string;
148
+ };
149
+
150
+ /**
151
+ * EXPORT
152
+ */
153
+ export type { ITravelHistory };
@@ -1,50 +1,89 @@
1
- /**
2
- * IMPORTS
3
- */
4
-
5
- //typngs
6
- import type { DayInfo } from "../interface";
7
-
8
- /**
9
- *
10
- * @param dias
11
- * @returns
12
- */
13
- const handlecalcularTotalHoras = (dias: DayInfo[]): string => {
14
- let totalMinutos = 0;
15
-
16
- dias.forEach(({ entrada, saida }) => {
17
- if (!entrada || !saida || saida.toUpperCase() === "REP") return;
18
-
19
- const entradaSplit = entrada.split(":").map(Number);
20
- const saidaSplit = saida.split(":").map(Number);
21
-
22
- if (entradaSplit.length !== 2 || saidaSplit.length !== 2) return;
23
-
24
- const [h1, m1] = entradaSplit;
25
- const [h2, m2] = saidaSplit;
26
-
27
- if (
28
- typeof h1 !== "number" ||
29
- isNaN(h1) ||
30
- typeof m1 !== "number" ||
31
- isNaN(m1) ||
32
- typeof h2 !== "number" ||
33
- isNaN(h2) ||
34
- typeof m2 !== "number" ||
35
- isNaN(m2)
36
- )
37
- return;
38
-
39
- totalMinutos += h2 * 60 + m2 - (h1 * 60 + m1);
40
- });
41
-
42
- const horas = Math.floor(totalMinutos / 60);
43
- const minutos = totalMinutos % 60;
44
- return `${horas}:${minutos.toString().padStart(2, "0")}`;
45
- };
46
-
47
- /**
48
- * EXPORTS
49
- */
50
- export { handlecalcularTotalHoras };
1
+ /**
2
+ * IMPORTS
3
+ */
4
+
5
+ //typngs
6
+ import type { DayInfo } from "../interface";
7
+
8
+ /**
9
+ *
10
+ * @param dias
11
+ * @returns
12
+ */
13
+ const handlecalcularTotalHoras = (dias: DayInfo[]): string => {
14
+ let totalMinutos = 0;
15
+
16
+ dias.forEach(({ entrada, saida }) => {
17
+ if (!entrada || !saida || saida.toUpperCase() === "REP") return;
18
+
19
+ const entradaSplit = entrada.split(":").map(Number);
20
+ const saidaSplit = saida.split(":").map(Number);
21
+
22
+ if (entradaSplit.length !== 2 || saidaSplit.length !== 2) return;
23
+
24
+ const [h1, m1] = entradaSplit;
25
+ const [h2, m2] = saidaSplit;
26
+
27
+ if (
28
+ typeof h1 !== "number" ||
29
+ isNaN(h1) ||
30
+ typeof m1 !== "number" ||
31
+ isNaN(m1) ||
32
+ typeof h2 !== "number" ||
33
+ isNaN(h2) ||
34
+ typeof m2 !== "number" ||
35
+ isNaN(m2)
36
+ )
37
+ return;
38
+
39
+ totalMinutos += h2 * 60 + m2 - (h1 * 60 + m1);
40
+ });
41
+
42
+ const horas = Math.floor(totalMinutos / 60);
43
+ const minutos = totalMinutos % 60;
44
+ return `${horas}:${minutos.toString().padStart(2, "0")}`;
45
+ };
46
+
47
+ // fazendo um regex para ver se ná minha variavel tem o valor
48
+ const isTime = (v?: string) => !!v && /^\d{1,2}:\d{2}$/.test(v);
49
+
50
+ // retornando a duração de cada jornada para realizar o calculo
51
+ const toMinutes = (hhmm: string) => {
52
+ const [h, m] = hhmm.split(":").map(Number);
53
+ return h! * 60 + m!;
54
+ };
55
+
56
+ const handleCalcularTotalHoras = (dias: DayInfo[]): string => {
57
+ let totalMin = 0;
58
+
59
+ for (const { entrada, saida } of dias) {
60
+ // ignorar quando encontrar repouso
61
+ if (saida?.toUpperCase() === "REP" || entrada?.toUpperCase() === "REP") continue;
62
+
63
+ const entradaIsTime = isTime(entrada);
64
+ const saidaIsTime = isTime(saida);
65
+
66
+ if (entradaIsTime && saidaIsTime) {
67
+ // diferença entre horários (suporta virar o dia)
68
+ let start = toMinutes(entrada!);
69
+ let end = toMinutes(saida!);
70
+ if (end < start) end += 24 * 60; // atravessou meia-noite
71
+ totalMin += end - start;
72
+ } else if (saidaIsTime && !entradaIsTime) {
73
+ // considerar 'saida' como DURAÇÃO do dia
74
+ totalMin += toMinutes(saida!);
75
+ } else if (entradaIsTime && !saidaIsTime) {
76
+ // considerar 'entrada' como DURAÇÃO do dia (fallback)
77
+ totalMin += toMinutes(entrada!);
78
+ }
79
+ }
80
+
81
+ const h = Math.floor(totalMin / 60);
82
+ const m = totalMin % 60;
83
+ return `${h}:${m.toString().padStart(2, "0")}`;
84
+ };
85
+
86
+ /**
87
+ * EXPORTS
88
+ */
89
+ export { handlecalcularTotalHoras, handleCalcularTotalHoras };