react-native-exp-fig 0.1.27 → 0.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/activity-timeline/components/activite-row/index.js +130 -0
- package/lib/commonjs/components/activity-timeline/components/activite-row/index.js.map +1 -0
- package/lib/commonjs/components/activity-timeline/index.js +78 -0
- package/lib/commonjs/components/activity-timeline/index.js.map +1 -0
- package/lib/commonjs/components/activity-timeline/interface.js +6 -0
- package/lib/commonjs/components/activity-timeline/interface.js.map +1 -0
- package/lib/commonjs/components/activity-timeline/styles.js +84 -0
- package/lib/commonjs/components/activity-timeline/styles.js.map +1 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/stories/activity-timeline/activity-timeline.stories.js +82 -0
- package/lib/commonjs/stories/activity-timeline/activity-timeline.stories.js.map +1 -0
- package/lib/module/components/activity-timeline/components/activite-row/index.js +123 -0
- package/lib/module/components/activity-timeline/components/activite-row/index.js.map +1 -0
- package/lib/module/components/activity-timeline/index.js +70 -0
- package/lib/module/components/activity-timeline/index.js.map +1 -0
- package/lib/module/components/activity-timeline/interface.js +2 -0
- package/lib/module/components/activity-timeline/interface.js.map +1 -0
- package/lib/module/components/activity-timeline/styles.js +78 -0
- package/lib/module/components/activity-timeline/styles.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/stories/activity-timeline/activity-timeline.stories.js +75 -0
- package/lib/module/stories/activity-timeline/activity-timeline.stories.js.map +1 -0
- package/lib/typescript/src/components/activity-timeline/components/activite-row/index.d.ts +10 -0
- package/lib/typescript/src/components/activity-timeline/index.d.ts +16 -0
- package/lib/typescript/src/components/activity-timeline/interface.d.ts +39 -0
- package/lib/typescript/src/components/activity-timeline/styles.d.ts +71 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/stories/activity-timeline/activity-timeline.stories.d.ts +8 -0
- package/package.json +1 -1
- package/src/components/activity-timeline/components/activite-row/index.tsx +133 -0
- package/src/components/activity-timeline/index.tsx +72 -0
- package/src/components/activity-timeline/interface.ts +53 -0
- package/src/components/activity-timeline/styles.ts +69 -0
- package/src/index.ts +1 -0
- package/src/stories/activity-timeline/activity-timeline.stories.tsx +90 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IMPORTS
|
|
3
|
+
*/
|
|
4
|
+
import React, { forwardRef, useCallback } from "react";
|
|
5
|
+
import { View, FlatList } from "react-native";
|
|
6
|
+
|
|
7
|
+
// components
|
|
8
|
+
import ActivityRows from "./components/activite-row";
|
|
9
|
+
|
|
10
|
+
// typings
|
|
11
|
+
import type { ActivityItemModel, ActivityTimelineProps } from "./interface";
|
|
12
|
+
import { asBaseComponent } from "../../@types/as-base-component";
|
|
13
|
+
|
|
14
|
+
// styles
|
|
15
|
+
import { styles, ROW_HEIGHT } from "./styles";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Componente ActivityTimeline para a interação da ui.
|
|
19
|
+
*/
|
|
20
|
+
const ActivityTimeline = forwardRef<any, ActivityTimelineProps<any>>(
|
|
21
|
+
(
|
|
22
|
+
{ data, onAdd, onEdit, onDelete, showIndexBadge = true, testID = "activity-timeline" },
|
|
23
|
+
ref
|
|
24
|
+
): React.ReactElement => {
|
|
25
|
+
const keyExtractor = useCallback((it: ActivityItemModel) => String(it.id), []);
|
|
26
|
+
|
|
27
|
+
const renderItem = useCallback(
|
|
28
|
+
({ item, index }: { item: ActivityItemModel; index: number }) => (
|
|
29
|
+
<ActivityRows
|
|
30
|
+
index={index}
|
|
31
|
+
items={data}
|
|
32
|
+
activities={item}
|
|
33
|
+
onAdd={onAdd}
|
|
34
|
+
onEdit={onEdit}
|
|
35
|
+
onDelete={onDelete}
|
|
36
|
+
showIndexBadge={showIndexBadge}
|
|
37
|
+
/>
|
|
38
|
+
),
|
|
39
|
+
[onAdd, onEdit, onDelete, showIndexBadge]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const getItemLayout = useCallback(
|
|
43
|
+
(_: any, index: number) => ({
|
|
44
|
+
length: ROW_HEIGHT,
|
|
45
|
+
offset: ROW_HEIGHT * index,
|
|
46
|
+
index,
|
|
47
|
+
}),
|
|
48
|
+
[]
|
|
49
|
+
);
|
|
50
|
+
return (
|
|
51
|
+
<FlatList
|
|
52
|
+
ref={ref}
|
|
53
|
+
testID={testID}
|
|
54
|
+
data={data}
|
|
55
|
+
keyExtractor={keyExtractor}
|
|
56
|
+
renderItem={renderItem}
|
|
57
|
+
contentContainerStyle={styles.listContainer}
|
|
58
|
+
getItemLayout={getItemLayout}
|
|
59
|
+
initialNumToRender={10}
|
|
60
|
+
maxToRenderPerBatch={10}
|
|
61
|
+
removeClippedSubviews
|
|
62
|
+
windowSize={7}
|
|
63
|
+
ListEmptyComponent={<View style={{ height: 8 }} />}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* EXPORTS
|
|
71
|
+
*/
|
|
72
|
+
export default asBaseComponent(ActivityTimeline);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IMPORTS
|
|
3
|
+
*/
|
|
4
|
+
import type { TouchableOpacityProps } from "react-native";
|
|
5
|
+
import type { SVG_NAME } from "../../common/icons-svg/constants";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* TYPES
|
|
9
|
+
*/
|
|
10
|
+
type ActivityId = string | number;
|
|
11
|
+
|
|
12
|
+
type ActivityItemModel = {
|
|
13
|
+
id: ActivityId;
|
|
14
|
+
title: string; // "Operação com veículo", "Refeição", ...
|
|
15
|
+
date: Date | string; // pode vir Date ou string já formatada
|
|
16
|
+
time: Date | string; // idem
|
|
17
|
+
invalid?: boolean; // destaca em vermelho
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type IconName = keyof typeof SVG_NAME;
|
|
21
|
+
|
|
22
|
+
type OnActivity = (item: ActivityItemModel) => void;
|
|
23
|
+
|
|
24
|
+
type ActivityTimelineProps<T> = TouchableOpacityProps & {
|
|
25
|
+
data: T[];
|
|
26
|
+
onAdd: OnActivity; // add novo após o item
|
|
27
|
+
onEdit: OnActivity;
|
|
28
|
+
onDelete: OnActivity;
|
|
29
|
+
showIndexBadge?: boolean; // mostra o “3/4/5”
|
|
30
|
+
testID?: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type IActivitieRowProps<T> = {
|
|
34
|
+
index: number;
|
|
35
|
+
activities: ActivityItemModel;
|
|
36
|
+
items: T[];
|
|
37
|
+
onAdd: OnActivity;
|
|
38
|
+
onEdit: OnActivity;
|
|
39
|
+
onDelete: OnActivity;
|
|
40
|
+
showIndexBadge?: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* EXPORTS
|
|
45
|
+
*/
|
|
46
|
+
export type {
|
|
47
|
+
ActivityId,
|
|
48
|
+
ActivityItemModel,
|
|
49
|
+
IconName,
|
|
50
|
+
OnActivity,
|
|
51
|
+
ActivityTimelineProps,
|
|
52
|
+
IActivitieRowProps,
|
|
53
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IMPORTS
|
|
3
|
+
*/
|
|
4
|
+
import { StyleSheet } from "react-native";
|
|
5
|
+
import { theme } from "../../styles/theme/theme";
|
|
6
|
+
|
|
7
|
+
export const ROW_HEIGHT = 72;
|
|
8
|
+
|
|
9
|
+
const styles = StyleSheet.create({
|
|
10
|
+
listContainer: { paddingVertical: 8 },
|
|
11
|
+
row: {
|
|
12
|
+
width: "100%",
|
|
13
|
+
minHeight: ROW_HEIGHT,
|
|
14
|
+
paddingVertical: 8,
|
|
15
|
+
paddingHorizontal: 8,
|
|
16
|
+
flexDirection: "row",
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
justifyContent: "center",
|
|
19
|
+
gap: 6,
|
|
20
|
+
},
|
|
21
|
+
badge: {
|
|
22
|
+
width: 28,
|
|
23
|
+
height: 28,
|
|
24
|
+
borderRadius: 14,
|
|
25
|
+
backgroundColor: theme.colors.blue[500],
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
justifyContent: "center",
|
|
28
|
+
},
|
|
29
|
+
card: {
|
|
30
|
+
flex: 1,
|
|
31
|
+
borderRadius: 10,
|
|
32
|
+
},
|
|
33
|
+
title: { marginBottom: 6 },
|
|
34
|
+
pill: {
|
|
35
|
+
flexDirection: "row",
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
borderWidth: 1,
|
|
38
|
+
borderRadius: 10,
|
|
39
|
+
paddingHorizontal: 10,
|
|
40
|
+
paddingVertical: 8,
|
|
41
|
+
gap: 4,
|
|
42
|
+
},
|
|
43
|
+
pillOk: {
|
|
44
|
+
backgroundColor: "#F3F3F5",
|
|
45
|
+
borderColor: "#C4D4E5",
|
|
46
|
+
},
|
|
47
|
+
pillInvalid: {
|
|
48
|
+
backgroundColor: "#FDE7E7",
|
|
49
|
+
borderColor: theme.colors.red[900],
|
|
50
|
+
},
|
|
51
|
+
sep: { marginHorizontal: 8, opacity: 0.5 },
|
|
52
|
+
actions: { flexDirection: "row", gap: 8 },
|
|
53
|
+
iconButton: {
|
|
54
|
+
width: 36,
|
|
55
|
+
height: 36,
|
|
56
|
+
borderRadius: 8,
|
|
57
|
+
backgroundColor: theme.colors.neutral[25],
|
|
58
|
+
borderWidth: 1,
|
|
59
|
+
borderColor: theme.colors.neutral[200],
|
|
60
|
+
alignItems: "center",
|
|
61
|
+
justifyContent: "center",
|
|
62
|
+
marginTop: 36,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* EXPORTS
|
|
68
|
+
*/
|
|
69
|
+
export { styles };
|
package/src/index.ts
CHANGED
|
@@ -40,6 +40,7 @@ export { default as ModalActivityReason } from "./components/modals/modal-activi
|
|
|
40
40
|
export { default as InputTextCounter } from "./components/input-text-counter";
|
|
41
41
|
export { default as ModalCreteActivitie } from "./components/modal-create-activitie";
|
|
42
42
|
export { default as ModalJourneyRectification } from "./components/modal-journey-rectification";
|
|
43
|
+
export { default as ActivityTimeline } from "./components/activity-timeline";
|
|
43
44
|
|
|
44
45
|
// Utilities
|
|
45
46
|
export { multiply } from "./utils/mutiply";
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import ActivityTimeline from "../../components/activity-timeline";
|
|
3
|
+
|
|
4
|
+
import type { ActivityItemModel } from "../../components/activity-timeline/interface";
|
|
5
|
+
|
|
6
|
+
const sampleData: ActivityItemModel[] = [
|
|
7
|
+
{
|
|
8
|
+
id: 1,
|
|
9
|
+
title: "Operação com veículo",
|
|
10
|
+
date: "24/03/2025",
|
|
11
|
+
time: "08:00",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: 2,
|
|
15
|
+
title: "Refeição",
|
|
16
|
+
date: "24/03/2025",
|
|
17
|
+
time: "12:30",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 3,
|
|
21
|
+
title: "Aguardando carga",
|
|
22
|
+
date: "24/03/2025",
|
|
23
|
+
time: "14:00",
|
|
24
|
+
invalid: true,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 4,
|
|
28
|
+
title: "Descanso",
|
|
29
|
+
date: "24/03/2025",
|
|
30
|
+
time: "18:45",
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const meta: Meta<typeof ActivityTimeline> = {
|
|
35
|
+
title: "componente/ActivityTimeline",
|
|
36
|
+
component: ActivityTimeline,
|
|
37
|
+
args: {
|
|
38
|
+
data: sampleData,
|
|
39
|
+
showIndexBadge: true,
|
|
40
|
+
onAdd: (item: ActivityItemModel) => console.log("onAdd", item),
|
|
41
|
+
onEdit: (item: ActivityItemModel) => console.log("onEdit", item),
|
|
42
|
+
onDelete: (item: ActivityItemModel) => console.log("onDelete", item),
|
|
43
|
+
},
|
|
44
|
+
parameters: {
|
|
45
|
+
notes: `
|
|
46
|
+
# ActivityTimeline
|
|
47
|
+
|
|
48
|
+
Lista de atividades com ações de adicionar, editar e excluir.
|
|
49
|
+
|
|
50
|
+
Exemplo de uso:
|
|
51
|
+
|
|
52
|
+
\`\`\`tsx
|
|
53
|
+
<ActivityTimeline
|
|
54
|
+
data={data}
|
|
55
|
+
showIndexBadge
|
|
56
|
+
onAdd={(item) => console.log('onAdd', item)}
|
|
57
|
+
onEdit={(item) => console.log('onEdit', item)}
|
|
58
|
+
onDelete={(item) => console.log('onDelete', item)}
|
|
59
|
+
/>
|
|
60
|
+
\`\`\`
|
|
61
|
+
`,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default meta;
|
|
66
|
+
|
|
67
|
+
type Story = StoryObj<typeof meta>;
|
|
68
|
+
|
|
69
|
+
export const Padrao: Story = {
|
|
70
|
+
name: "activity-timeline-padrao",
|
|
71
|
+
args: {
|
|
72
|
+
data: sampleData,
|
|
73
|
+
showIndexBadge: true,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const SemBadge: Story = {
|
|
78
|
+
name: "activity-timeline-sem-badge",
|
|
79
|
+
args: {
|
|
80
|
+
data: sampleData,
|
|
81
|
+
showIndexBadge: false,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const ListaVazia: Story = {
|
|
86
|
+
name: "activity-timeline-lista-vazia",
|
|
87
|
+
args: {
|
|
88
|
+
data: [],
|
|
89
|
+
},
|
|
90
|
+
};
|