jornada-ui 0.4.12 → 0.4.14

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 (106) hide show
  1. package/lib/commonjs/components/coil-removel-code/index.js +4 -3
  2. package/lib/commonjs/components/coil-removel-code/index.js.map +1 -1
  3. package/lib/commonjs/components/list-devices/components/list-device-empty/index.js +68 -0
  4. package/lib/commonjs/components/list-devices/components/list-device-empty/index.js.map +1 -0
  5. package/lib/commonjs/components/list-devices/components/list-device-render-item/index.js +77 -0
  6. package/lib/commonjs/components/list-devices/components/list-device-render-item/index.js.map +1 -0
  7. package/lib/commonjs/components/list-devices/index.js +33 -58
  8. package/lib/commonjs/components/list-devices/index.js.map +1 -1
  9. package/lib/commonjs/components/list-devices/interface.js +2 -0
  10. package/lib/commonjs/components/list-devices/interface.js.map +1 -0
  11. package/lib/commonjs/components/list-devices/styles.js +14 -3
  12. package/lib/commonjs/components/list-devices/styles.js.map +1 -1
  13. package/lib/commonjs/components/modals/modal-to-confimations/index.js +1 -1
  14. package/lib/commonjs/components/modals/modal-to-confimations/index.js.map +1 -1
  15. package/lib/commonjs/components/selects/select-option/index.js +22 -7
  16. package/lib/commonjs/components/selects/select-option/index.js.map +1 -1
  17. package/lib/commonjs/components/step-indicator/index.js +54 -40
  18. package/lib/commonjs/components/step-indicator/index.js.map +1 -1
  19. package/lib/commonjs/components/step-indicator/styles.js.map +1 -1
  20. package/lib/commonjs/components/trip-details-card/index.js +8 -9
  21. package/lib/commonjs/components/trip-details-card/index.js.map +1 -1
  22. package/lib/commonjs/stories/step-indicator/step-indicator.stories.js +1 -0
  23. package/lib/commonjs/stories/step-indicator/step-indicator.stories.js.map +1 -1
  24. package/lib/commonjs/utils/text-limit/index.js +37 -0
  25. package/lib/commonjs/utils/text-limit/index.js.map +1 -0
  26. package/lib/module/components/coil-removel-code/index.js +4 -3
  27. package/lib/module/components/coil-removel-code/index.js.map +1 -1
  28. package/lib/module/components/list-devices/components/list-device-empty/index.js +63 -0
  29. package/lib/module/components/list-devices/components/list-device-empty/index.js.map +1 -0
  30. package/lib/module/components/list-devices/components/list-device-render-item/index.js +74 -0
  31. package/lib/module/components/list-devices/components/list-device-render-item/index.js.map +1 -0
  32. package/lib/module/components/list-devices/index.js +36 -61
  33. package/lib/module/components/list-devices/index.js.map +1 -1
  34. package/lib/module/components/list-devices/interface.js +2 -0
  35. package/lib/module/components/list-devices/interface.js.map +1 -0
  36. package/lib/module/components/list-devices/styles.js +14 -3
  37. package/lib/module/components/list-devices/styles.js.map +1 -1
  38. package/lib/module/components/modals/modal-to-confimations/index.js +1 -1
  39. package/lib/module/components/modals/modal-to-confimations/index.js.map +1 -1
  40. package/lib/module/components/selects/select-option/index.js +22 -7
  41. package/lib/module/components/selects/select-option/index.js.map +1 -1
  42. package/lib/module/components/step-indicator/index.js +55 -41
  43. package/lib/module/components/step-indicator/index.js.map +1 -1
  44. package/lib/module/components/step-indicator/styles.js.map +1 -1
  45. package/lib/module/components/trip-details-card/index.js +11 -11
  46. package/lib/module/components/trip-details-card/index.js.map +1 -1
  47. package/lib/module/stories/step-indicator/step-indicator.stories.js +1 -0
  48. package/lib/module/stories/step-indicator/step-indicator.stories.js.map +1 -1
  49. package/lib/module/utils/text-limit/index.js +32 -0
  50. package/lib/module/utils/text-limit/index.js.map +1 -0
  51. package/lib/typescript/commonjs/src/components/coil-removel-code/index.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/src/components/list-devices/components/list-device-empty/index.d.ts +10 -0
  53. package/lib/typescript/commonjs/src/components/list-devices/components/list-device-empty/index.d.ts.map +1 -0
  54. package/lib/typescript/commonjs/src/components/list-devices/components/list-device-render-item/index.d.ts +22 -0
  55. package/lib/typescript/commonjs/src/components/list-devices/components/list-device-render-item/index.d.ts.map +1 -0
  56. package/lib/typescript/commonjs/src/components/list-devices/index.d.ts.map +1 -1
  57. package/lib/typescript/commonjs/src/components/list-devices/interface.d.ts +29 -0
  58. package/lib/typescript/commonjs/src/components/list-devices/interface.d.ts.map +1 -0
  59. package/lib/typescript/commonjs/src/components/list-devices/styles.d.ts +5 -5
  60. package/lib/typescript/commonjs/src/components/list-devices/styles.d.ts.map +1 -1
  61. package/lib/typescript/commonjs/src/components/selects/select-option/index.d.ts.map +1 -1
  62. package/lib/typescript/commonjs/src/components/step-indicator/index.d.ts.map +1 -1
  63. package/lib/typescript/commonjs/src/components/step-indicator/styles.d.ts +2 -2
  64. package/lib/typescript/commonjs/src/components/step-indicator/styles.d.ts.map +1 -1
  65. package/lib/typescript/commonjs/src/components/trip-details-card/index.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/src/stories/step-indicator/step-indicator.stories.d.ts.map +1 -1
  67. package/lib/typescript/commonjs/src/utils/text-limit/index.d.ts +14 -0
  68. package/lib/typescript/commonjs/src/utils/text-limit/index.d.ts.map +1 -0
  69. package/lib/typescript/module/src/components/coil-removel-code/index.d.ts.map +1 -1
  70. package/lib/typescript/module/src/components/list-devices/components/list-device-empty/index.d.ts +10 -0
  71. package/lib/typescript/module/src/components/list-devices/components/list-device-empty/index.d.ts.map +1 -0
  72. package/lib/typescript/module/src/components/list-devices/components/list-device-render-item/index.d.ts +22 -0
  73. package/lib/typescript/module/src/components/list-devices/components/list-device-render-item/index.d.ts.map +1 -0
  74. package/lib/typescript/module/src/components/list-devices/index.d.ts.map +1 -1
  75. package/lib/typescript/module/src/components/list-devices/interface.d.ts +29 -0
  76. package/lib/typescript/module/src/components/list-devices/interface.d.ts.map +1 -0
  77. package/lib/typescript/module/src/components/list-devices/styles.d.ts +5 -5
  78. package/lib/typescript/module/src/components/list-devices/styles.d.ts.map +1 -1
  79. package/lib/typescript/module/src/components/selects/select-option/index.d.ts.map +1 -1
  80. package/lib/typescript/module/src/components/step-indicator/index.d.ts.map +1 -1
  81. package/lib/typescript/module/src/components/step-indicator/styles.d.ts +2 -2
  82. package/lib/typescript/module/src/components/step-indicator/styles.d.ts.map +1 -1
  83. package/lib/typescript/module/src/components/trip-details-card/index.d.ts.map +1 -1
  84. package/lib/typescript/module/src/stories/step-indicator/step-indicator.stories.d.ts.map +1 -1
  85. package/lib/typescript/module/src/utils/text-limit/index.d.ts +14 -0
  86. package/lib/typescript/module/src/utils/text-limit/index.d.ts.map +1 -0
  87. package/package.json +1 -1
  88. package/src/components/coil-removel-code/index.tsx +8 -3
  89. package/src/components/coil-removel-code/interface.d.ts +14 -13
  90. package/src/components/list-devices/components/list-device-empty/index.tsx +60 -0
  91. package/src/components/list-devices/components/list-device-render-item/index.tsx +86 -0
  92. package/src/components/list-devices/index.tsx +71 -102
  93. package/src/components/list-devices/{interface.d.ts → interface.ts} +36 -36
  94. package/src/components/list-devices/styles.ts +73 -68
  95. package/src/components/modals/modal-to-confimations/index.tsx +1 -1
  96. package/src/components/selects/select-option/index.tsx +124 -95
  97. package/src/components/step-indicator/index.tsx +56 -36
  98. package/src/components/step-indicator/interface.d.ts +14 -3
  99. package/src/components/step-indicator/styles.ts +2 -2
  100. package/src/components/trip-details-card/index.tsx +267 -270
  101. package/src/stories/step-indicator/step-indicator.stories.tsx +1 -0
  102. package/src/utils/text-limit/index.ts +28 -0
  103. package/lib/commonjs/components/list-devices/interface.d.js +0 -2
  104. package/lib/commonjs/components/list-devices/interface.d.js.map +0 -1
  105. package/lib/module/components/list-devices/interface.d.js +0 -2
  106. package/lib/module/components/list-devices/interface.d.js.map +0 -1
@@ -0,0 +1,86 @@
1
+ /* eslint-disable no-unused-vars */
2
+
3
+ /**
4
+ * IMPORTS
5
+ */
6
+ import React, { useMemo } from "react";
7
+
8
+ import { Text, TouchableOpacity, View } from "react-native";
9
+
10
+ // commons / svg
11
+ import { Icons } from "../../../../common/icons-svg";
12
+
13
+ // typings
14
+ import type { IData } from "../../interface";
15
+
16
+ // styles
17
+ import { theme } from "../../../../styles/theme/theme";
18
+ import { styles as makeStyles } from "../../styles";
19
+
20
+ /**
21
+ * Componente DeviceRow para a exibição de um item da lista de dispositivos
22
+ */
23
+ const DeviceRow = React.memo(function DeviceRow({
24
+ device,
25
+ isSelected,
26
+ isLast,
27
+ disabled,
28
+ onPress,
29
+ titleColor,
30
+ textColorDescription,
31
+ }: {
32
+ device: IData;
33
+ isSelected: boolean;
34
+ isLast: boolean;
35
+ disabled?: boolean;
36
+ onPress: (d: IData) => void;
37
+ titleColor?: string;
38
+ textColorDescription?: string;
39
+ }) {
40
+ // estilos base/memoizados (evite recriar objetos grandes)
41
+ const s = useMemo(
42
+ () =>
43
+ makeStyles({
44
+ titleColor,
45
+ textColorDescription,
46
+ disabled,
47
+ isSelected,
48
+ }),
49
+ [titleColor, textColorDescription, disabled, isSelected]
50
+ );
51
+
52
+ return (
53
+ <TouchableOpacity
54
+ activeOpacity={0.7}
55
+ testID="list-devices"
56
+ onPress={() => onPress(device)}
57
+ disabled={disabled}
58
+ accessibilityRole="button"
59
+ accessibilityState={{ selected: isSelected, disabled }}
60
+ accessibilityLabel={`Dispositivo ${device.nameDevice}`}
61
+ style={[
62
+ s.containerIndicator,
63
+ !isLast && s.separator,
64
+ isSelected && s.containerIndicatorSelected,
65
+ ]}
66
+ >
67
+ <Icons
68
+ icon="BLUETOOTH"
69
+ size={26}
70
+ background={theme.colors.gray[600]}
71
+ color={theme.colors.gray[300]}
72
+ />
73
+ <View style={s.containerMain}>
74
+ <Text style={[s.title, isSelected && s.titleSelected]}>{device.nameDevice}</Text>
75
+ {!!device.macDevice && (
76
+ <Text style={[s.titleDescription, isSelected && s.descSelected]}>{device.macDevice}</Text>
77
+ )}
78
+ </View>
79
+ </TouchableOpacity>
80
+ );
81
+ });
82
+
83
+ /**
84
+ * EXPORTS
85
+ */
86
+ export { DeviceRow };
@@ -1,102 +1,71 @@
1
- /**
2
- * IMPORTS
3
- */
4
- import React, { forwardRef } from "react";
5
- import { View, Text, TouchableOpacity } from "react-native";
6
-
7
- // components
8
- import Box from "../box";
9
-
10
- // icons
11
- import { Icons } from "../../common/icons-svg";
12
-
13
- // typings
14
- import type { IListDevices, IData } from "./interface";
15
- import { asBaseComponent } from "../../@types/as-base-component";
16
-
17
- // styles
18
- import { styles as makeStyles } from "./styles";
19
- import { theme } from "../../styles/theme/theme";
20
-
21
- /**
22
- * Componente ListDevices para a interação da ui.
23
- */
24
- const ListDevices = forwardRef<any, IListDevices>(
25
- (
26
- { data, textColorDescription, titleColor, selectedId, onSelect, defaultSelectedId, disabled },
27
- ref
28
- ): React.ReactElement => {
29
- const isControlled = selectedId !== undefined;
30
- const [internalSelected, setInternalSelected] = React.useState<number | null>(
31
- defaultSelectedId!
32
- );
33
-
34
- const currentSelected = isControlled ? (selectedId ?? null) : internalSelected;
35
-
36
- const handlePress = (device: IData) => {
37
- if (disabled) return;
38
- if (!isControlled) setInternalSelected(device.id);
39
- onSelect?.(device);
40
- };
41
-
42
- if (!data?.length) return <Box />;
43
-
44
- return (
45
- <>
46
- {data.map((history, index) => {
47
- const isLast = index === data.length - 1;
48
- const isSelected = currentSelected === history.id;
49
-
50
- const s = makeStyles({
51
- titleColor,
52
- textColorDescription,
53
- disabled,
54
- isSelected,
55
- });
56
-
57
- return (
58
- <TouchableOpacity
59
- ref={ref}
60
- activeOpacity={0.7}
61
- testID="list-devices"
62
- key={history.id}
63
- onPress={() => handlePress(history)}
64
- disabled={disabled}
65
- accessibilityRole="button"
66
- accessibilityState={{ selected: isSelected, disabled }}
67
- accessibilityLabel={`Dispositivo ${history.nameDevice}`}
68
- style={[
69
- s.containerIndicator,
70
- !isLast && s.separator,
71
- isSelected && s.containerIndicatorSelected,
72
- ]}
73
- >
74
- <Icons
75
- icon={"BLUETOOTH"}
76
- size={26}
77
- background={theme.colors.gray[600]}
78
- color={theme.colors.gray[300]}
79
- />
80
-
81
- <View style={s.containerMain}>
82
- <Text style={[s.title, isSelected && s.titleSelected]}>{history.nameDevice}</Text>
83
- {!!history.macDevice && (
84
- <Text style={[s.titleDescription, isSelected && s.descSelected]}>
85
- {history.macDevice}
86
- </Text>
87
- )}
88
- </View>
89
- </TouchableOpacity>
90
- );
91
- })}
92
- </>
93
- );
94
- }
95
- );
96
-
97
- ListDevices.displayName = "ListDevices";
98
-
99
- /**
100
- * EXPORTS
101
- */
102
- export default asBaseComponent(ListDevices);
1
+ /**
2
+ * IMPORTS
3
+ */
4
+ import React, { forwardRef, useCallback } from "react";
5
+ import { FlatList, type ListRenderItem } from "react-native";
6
+
7
+ import { DeviceRow } from "./components/list-device-render-item";
8
+ import ListDeviceEmpty from "./components/list-device-empty";
9
+
10
+ // typings
11
+ import type { IListDevices, IData } from "./interface";
12
+ import { asBaseComponent } from "../../@types/as-base-component";
13
+
14
+ /**
15
+ * Componente ListDevices para a interação da ui.
16
+ */
17
+ const ListDevices = forwardRef<any, IListDevices>(
18
+ (
19
+ { data, textColorDescription, titleColor, selectedId, onSelect, defaultSelectedId, disabled },
20
+ ref
21
+ ): React.ReactElement => {
22
+ const isControlled = selectedId !== undefined;
23
+ const [internalSelected, setInternalSelected] = React.useState<number | null>(
24
+ defaultSelectedId ?? null
25
+ );
26
+
27
+ const currentSelected = isControlled ? (selectedId ?? null) : internalSelected;
28
+
29
+ const handlePress = (device: IData) => {
30
+ if (disabled) return;
31
+ if (!isControlled) setInternalSelected(device.id);
32
+ onSelect?.(device);
33
+ };
34
+
35
+ const renderItem: ListRenderItem<IData> = useCallback(
36
+ ({ item: device, index }) => {
37
+ const isLast = index === data?.length! - 1;
38
+ const isSelected = currentSelected === device.id;
39
+ return (
40
+ <DeviceRow
41
+ device={device}
42
+ isSelected={isSelected}
43
+ isLast={isLast}
44
+ disabled={disabled}
45
+ onPress={handlePress}
46
+ titleColor={titleColor}
47
+ textColorDescription={textColorDescription}
48
+ />
49
+ );
50
+ },
51
+ [currentSelected, disabled, handlePress, titleColor, textColorDescription]
52
+ );
53
+
54
+ return (
55
+ <FlatList
56
+ ref={ref}
57
+ data={data}
58
+ keyExtractor={({ id }) => String(id)}
59
+ renderItem={renderItem}
60
+ ListEmptyComponent={ListDeviceEmpty}
61
+ />
62
+ );
63
+ }
64
+ );
65
+
66
+ ListDevices.displayName = "ListDevices";
67
+
68
+ /**
69
+ * EXPORTS
70
+ */
71
+ export default asBaseComponent(ListDevices);
@@ -1,36 +1,36 @@
1
- /* eslint-disable no-unused-vars */
2
- /**
3
- * IMPORTS
4
- */
5
-
6
- export type IData = {
7
- id: number;
8
- macDevice: string;
9
- nameDevice: string;
10
- };
11
-
12
- export interface IListDevices {
13
- /** dados que vão ser renderizados */
14
- data?: IData[];
15
-
16
- /** cor do texto */
17
- titleColor?: string;
18
-
19
- /** cor do titulo (não está sendo usada no componente atual, mantida por compat) */
20
- titleNumberColor?: string;
21
-
22
- /** cor do texto da descrição */
23
- textColorDescription?: string;
24
-
25
- /** (opcional) id selecionado - modo controlado */
26
- selectedId?: number | null;
27
-
28
- /** (opcional) seleção inicial - modo não-controlado */
29
- defaultSelectedId?: number | null;
30
-
31
- /** callback ao selecionar um item */
32
- onSelect?: (device: IData) => void;
33
-
34
- /** desabilita interação */
35
- disabled?: boolean;
36
- }
1
+ /* eslint-disable no-unused-vars */
2
+ interface IData {
3
+ id: number;
4
+ macDevice: string;
5
+ nameDevice: string;
6
+ }
7
+
8
+ type Extra = { disabled?: boolean; isSelected?: boolean };
9
+
10
+ interface IListDevices {
11
+ /** dados que vão ser renderizados */
12
+ data?: IData[];
13
+
14
+ /** cor do texto */
15
+ titleColor?: string;
16
+
17
+ /** cor do titulo (não está sendo usada no componente atual, mantida por compat) */
18
+ titleNumberColor?: string;
19
+
20
+ /** cor do texto da descrição */
21
+ textColorDescription?: string;
22
+
23
+ /** (opcional) id selecionado - modo controlado */
24
+ selectedId?: number | null;
25
+
26
+ /** (opcional) seleção inicial - modo não-controlado */
27
+ defaultSelectedId?: number | null;
28
+
29
+ /** callback ao selecionar um item */
30
+ onSelect?: (device: IData) => void;
31
+
32
+ /** desabilita interação */
33
+ disabled?: boolean;
34
+ }
35
+
36
+ export type { IData, IListDevices, Extra };
@@ -1,68 +1,73 @@
1
- import { StyleSheet } from "react-native";
2
- import { type IListDevices } from "./interface";
3
- import { theme } from "../../styles/theme/theme";
4
-
5
- type Extra = { disabled?: boolean; isSelected?: boolean };
6
-
7
- const styles = (props: Partial<IListDevices & Extra> = {}) =>
8
- StyleSheet.create({
9
- containerIndicator: {
10
- width: "100%",
11
- flexDirection: "row",
12
- justifyContent: "flex-start",
13
- alignItems: "center",
14
- marginTop: 8,
15
- paddingVertical: 8,
16
- paddingHorizontal: 8,
17
- opacity: props.disabled ? 0.6 : 1,
18
- },
19
-
20
- containerIndicatorSelected: {
21
- backgroundColor: theme.colors.green[250],
22
- borderRadius: 30,
23
- },
24
-
25
- separator: {
26
- borderBottomWidth: 1,
27
- borderBottomColor: props.isSelected
28
- ? "transparent"
29
- : theme.colors.gray[700],
30
- },
31
-
32
- title: {
33
- color: props.titleColor ?? theme.colors.black[10],
34
- textAlign: "center",
35
- lineHeight: 20,
36
- fontSize: theme.fontSizes.sm,
37
- fontWeight: "500",
38
- marginLeft: theme.margins.xs,
39
- },
40
-
41
- titleSelected: {
42
- color: theme.colors.neutral[25],
43
- fontWeight: "600",
44
- },
45
-
46
- titleDescription: {
47
- color: props.textColorDescription ?? theme.colors.gray[600],
48
- textAlign: "center",
49
- lineHeight: 16,
50
- fontSize: 18,
51
- fontFamily: theme.fonts.inter_light_300,
52
- marginLeft: theme.margins.xs,
53
- },
54
-
55
- descSelected: {
56
- color: theme.colors.neutral[25],
57
- },
58
-
59
- containerMain: {
60
- width: "100%",
61
- flexDirection: "column",
62
- alignItems: "flex-start",
63
- marginLeft: 2,
64
- justifyContent: "center",
65
- },
66
- });
67
-
68
- export { styles };
1
+ /**
2
+ * IMPORTS
3
+ */
4
+ import { StyleSheet } from "react-native";
5
+ import { theme } from "../../styles/theme/theme";
6
+
7
+ // typings
8
+ import { type IListDevices, type Extra } from "./interface";
9
+
10
+ const styles = (props: Partial<IListDevices & Extra> = {}) =>
11
+ StyleSheet.create({
12
+ containerIndicator: {
13
+ width: "100%",
14
+ flexDirection: "row",
15
+ justifyContent: "flex-start",
16
+ alignItems: "center",
17
+ marginTop: 8,
18
+ paddingVertical: 8,
19
+ paddingHorizontal: 8,
20
+ opacity: props.disabled ? 0.6 : 1,
21
+ },
22
+
23
+ containerIndicatorSelected: {
24
+ backgroundColor: theme.colors.green[250],
25
+ borderRadius: 30,
26
+ },
27
+
28
+ separator: {
29
+ borderBottomWidth: 1,
30
+ borderBottomColor: props.isSelected ? "transparent" : theme.colors.gray[700],
31
+ },
32
+
33
+ title: {
34
+ color: props.titleColor ?? theme.colors.black[10],
35
+ textAlign: "center",
36
+ lineHeight: 20,
37
+ fontSize: theme.fontSizes.lg,
38
+ fontWeight: "500",
39
+ marginLeft: theme.margins.xs,
40
+ marginBottom: 8,
41
+ },
42
+
43
+ titleSelected: {
44
+ color: theme.colors.neutral[25],
45
+ fontWeight: "600",
46
+ },
47
+
48
+ titleDescription: {
49
+ color: props.textColorDescription ?? theme.colors.gray[600],
50
+ textAlign: "center",
51
+ lineHeight: 16,
52
+ fontSize: theme.fontSizes.md,
53
+ fontFamily: theme.fonts.inter_light_300,
54
+ marginLeft: theme.margins.xs,
55
+ },
56
+
57
+ descSelected: {
58
+ color: theme.colors.neutral[25],
59
+ },
60
+
61
+ containerMain: {
62
+ width: "100%",
63
+ flexDirection: "column",
64
+ alignItems: "flex-start",
65
+ marginLeft: 2,
66
+ justifyContent: "center",
67
+ },
68
+ });
69
+
70
+ /**
71
+ * EXPORTS
72
+ */
73
+ export { styles };
@@ -101,7 +101,7 @@ const ModalToConfirmations: React.FC<IModalToConfirmationsProps> = ({
101
101
  lineHeight={24}
102
102
  letterSpacing={"regular"}
103
103
  />
104
- {text2 ?? "Alterar?"}
104
+ {text2}
105
105
  </Text>
106
106
  </Box>
107
107