@terreno/ui 57.3.0 → 57.4.0
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/dist/AnnouncementBanner.d.ts +12 -0
- package/dist/AnnouncementBanner.js +61 -0
- package/dist/AnnouncementBanner.js.map +1 -0
- package/dist/AnnouncementNavigator.d.ts +11 -0
- package/dist/AnnouncementNavigator.js +189 -0
- package/dist/AnnouncementNavigator.js.map +1 -0
- package/dist/AnnouncementScreen.d.ts +12 -0
- package/dist/AnnouncementScreen.js +28 -0
- package/dist/AnnouncementScreen.js.map +1 -0
- package/dist/AreaChart.d.ts +5 -0
- package/dist/AreaChart.js +69 -0
- package/dist/AreaChart.js.map +1 -0
- package/dist/BarChart.d.ts +5 -0
- package/dist/BarChart.js +89 -0
- package/dist/BarChart.js.map +1 -0
- package/dist/Button.js +17 -3
- package/dist/Button.js.map +1 -1
- package/dist/Common.d.ts +96 -0
- package/dist/Common.js.map +1 -1
- package/dist/DashboardGrid.d.ts +4 -0
- package/dist/DashboardGrid.js +38 -0
- package/dist/DashboardGrid.js.map +1 -0
- package/dist/DataTable.js +83 -11
- package/dist/DataTable.js.map +1 -1
- package/dist/DonutChart.d.ts +5 -0
- package/dist/DonutChart.js +84 -0
- package/dist/DonutChart.js.map +1 -0
- package/dist/Filter.js +12 -2
- package/dist/Filter.js.map +1 -1
- package/dist/GPTChat.d.ts +7 -1
- package/dist/GPTChat.js +28 -15
- package/dist/GPTChat.js.map +1 -1
- package/dist/LineChart.d.ts +5 -0
- package/dist/LineChart.js +68 -0
- package/dist/LineChart.js.map +1 -0
- package/dist/MarkdownEmbed.d.ts +6 -0
- package/dist/MarkdownEmbed.js +17 -0
- package/dist/MarkdownEmbed.js.map +1 -0
- package/dist/MarkdownView.js +38 -3
- package/dist/MarkdownView.js.map +1 -1
- package/dist/Modal.js +12 -10
- package/dist/Modal.js.map +1 -1
- package/dist/ModalSheet.d.ts +5 -1
- package/dist/ModalSheet.js +31 -13
- package/dist/ModalSheet.js.map +1 -1
- package/dist/MultiselectField.js +4 -9
- package/dist/MultiselectField.js.map +1 -1
- package/dist/NotificationBell.d.ts +16 -0
- package/dist/NotificationBell.js +15 -0
- package/dist/NotificationBell.js.map +1 -0
- package/dist/NotificationInbox.d.ts +21 -0
- package/dist/NotificationInbox.js +41 -0
- package/dist/NotificationInbox.js.map +1 -0
- package/dist/NotificationPreferences.d.ts +14 -0
- package/dist/NotificationPreferences.js +32 -0
- package/dist/NotificationPreferences.js.map +1 -0
- package/dist/TextField.js +83 -6
- package/dist/TextField.js.map +1 -1
- package/dist/announcementBuildVersion.d.ts +6 -0
- package/dist/announcementBuildVersion.js +21 -0
- package/dist/announcementBuildVersion.js.map +1 -0
- package/dist/announcementFrequency.d.ts +42 -0
- package/dist/announcementFrequency.js +163 -0
- package/dist/announcementFrequency.js.map +1 -0
- package/dist/announcementPlatform.d.ts +2 -0
- package/dist/announcementPlatform.js +11 -0
- package/dist/announcementPlatform.js.map +1 -0
- package/dist/charts/ChartFrame.d.ts +12 -0
- package/dist/charts/ChartFrame.js +13 -0
- package/dist/charts/ChartFrame.js.map +1 -0
- package/dist/charts/bars.d.ts +18 -0
- package/dist/charts/bars.js +29 -0
- package/dist/charts/bars.js.map +1 -0
- package/dist/charts/layout.d.ts +47 -0
- package/dist/charts/layout.js +56 -0
- package/dist/charts/layout.js.map +1 -0
- package/dist/charts/paths.d.ts +31 -0
- package/dist/charts/paths.js +52 -0
- package/dist/charts/paths.js.map +1 -0
- package/dist/charts/scales.d.ts +6 -0
- package/dist/charts/scales.js +43 -0
- package/dist/charts/scales.js.map +1 -0
- package/dist/charts/theme.d.ts +9 -0
- package/dist/charts/theme.js +15 -0
- package/dist/charts/theme.js.map +1 -0
- package/dist/charts/types/chartTypes.d.ts +17 -0
- package/dist/charts/types/chartTypes.js +2 -0
- package/dist/charts/types/chartTypes.js.map +1 -0
- package/dist/dashboardGridLayout.d.ts +22 -0
- package/dist/dashboardGridLayout.js +33 -0
- package/dist/dashboardGridLayout.js.map +1 -0
- package/dist/dataTableFilters.d.ts +33 -0
- package/dist/dataTableFilters.js +221 -0
- package/dist/dataTableFilters.js.map +1 -0
- package/dist/dataTableListQuery.d.ts +42 -0
- package/dist/dataTableListQuery.js +161 -0
- package/dist/dataTableListQuery.js.map +1 -0
- package/dist/index.d.ts +18 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts +12 -0
- package/dist/lazyBoundaries/heavyOptionalExports.js +8 -0
- package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -1
- package/dist/markdownEmbeds.d.ts +6 -0
- package/dist/markdownEmbeds.js +59 -0
- package/dist/markdownEmbeds.js.map +1 -0
- package/dist/testing/resolveTestId.js +2 -1
- package/dist/testing/resolveTestId.js.map +1 -1
- package/dist/testing/types.d.ts +3 -0
- package/dist/textFieldOscillationGuard.d.ts +25 -0
- package/dist/textFieldOscillationGuard.js +41 -0
- package/dist/textFieldOscillationGuard.js.map +1 -0
- package/dist/useAcknowledgeAnnouncement.d.ts +71 -0
- package/dist/useAcknowledgeAnnouncement.js +94 -0
- package/dist/useAcknowledgeAnnouncement.js.map +1 -0
- package/dist/useAnnouncements.d.ts +73 -0
- package/dist/useAnnouncements.js +66 -0
- package/dist/useAnnouncements.js.map +1 -0
- package/package.json +7 -18
- package/src/AnnouncementBanner.test.tsx +267 -0
- package/src/AnnouncementBanner.tsx +128 -0
- package/src/AnnouncementNavigator.test.tsx +759 -0
- package/src/AnnouncementNavigator.tsx +287 -0
- package/src/AnnouncementScreen.test.tsx +97 -0
- package/src/AnnouncementScreen.tsx +70 -0
- package/src/AreaChart.test.tsx +68 -0
- package/src/AreaChart.tsx +194 -0
- package/src/BarChart.test.tsx +96 -0
- package/src/BarChart.tsx +208 -0
- package/src/Button.test.tsx +66 -0
- package/src/Button.tsx +17 -2
- package/src/Common.ts +95 -0
- package/src/ConsentNavigator.test.tsx +55 -0
- package/src/DashboardGrid.test.tsx +75 -0
- package/src/DashboardGrid.tsx +69 -0
- package/src/DataTable.test.tsx +296 -1
- package/src/DataTable.tsx +210 -18
- package/src/DonutChart.test.tsx +121 -0
- package/src/DonutChart.tsx +160 -0
- package/src/EmojiSelector.test.tsx +51 -0
- package/src/Field.test.tsx +18 -0
- package/src/Filter.test.tsx +25 -0
- package/src/Filter.tsx +38 -7
- package/src/GPTChat.test.tsx +107 -0
- package/src/GPTChat.tsx +176 -86
- package/src/LineChart.test.tsx +166 -0
- package/src/LineChart.tsx +190 -0
- package/src/MarkdownEmbed.test.tsx +34 -0
- package/src/MarkdownEmbed.tsx +43 -0
- package/src/MarkdownView.test.tsx +59 -2
- package/src/MarkdownView.tsx +51 -3
- package/src/Modal.test.tsx +107 -14
- package/src/Modal.tsx +20 -8
- package/src/ModalSheet.test.tsx +121 -9
- package/src/ModalSheet.tsx +46 -11
- package/src/MultiselectField.test.tsx +21 -0
- package/src/MultiselectField.tsx +11 -13
- package/src/NotificationBell.test.tsx +91 -0
- package/src/NotificationBell.tsx +77 -0
- package/src/NotificationInbox.test.tsx +130 -0
- package/src/NotificationInbox.tsx +144 -0
- package/src/NotificationPreferences.test.tsx +25 -0
- package/src/NotificationPreferences.tsx +75 -0
- package/src/RootImportRegression.test.tsx +20 -0
- package/src/TextField.test.tsx +421 -0
- package/src/TextField.tsx +121 -4
- package/src/__snapshots__/Field.test.tsx.snap +22 -0
- package/src/__snapshots__/ModalSheet.test.tsx.snap +4 -1
- package/src/__snapshots__/TextArea.test.tsx.snap +5 -5
- package/src/__snapshots__/TextField.test.tsx.snap +5 -5
- package/src/announcementBuildVersion.test.ts +43 -0
- package/src/announcementBuildVersion.ts +21 -0
- package/src/announcementFrequency.test.ts +245 -0
- package/src/announcementFrequency.ts +246 -0
- package/src/announcementPlatform.test.ts +27 -0
- package/src/announcementPlatform.ts +13 -0
- package/src/charts/ChartFrame.tsx +67 -0
- package/src/charts/bars.test.ts +56 -0
- package/src/charts/bars.ts +53 -0
- package/src/charts/layout.test.ts +80 -0
- package/src/charts/layout.ts +99 -0
- package/src/charts/paths.test.ts +79 -0
- package/src/charts/paths.ts +100 -0
- package/src/charts/scales.test.ts +59 -0
- package/src/charts/scales.ts +60 -0
- package/src/charts/theme.test.ts +22 -0
- package/src/charts/theme.ts +24 -0
- package/src/charts/types/chartTypes.ts +19 -0
- package/src/dashboardGridLayout.test.ts +90 -0
- package/src/dashboardGridLayout.ts +60 -0
- package/src/dataTableFilters.test.tsx +552 -0
- package/src/dataTableFilters.tsx +441 -0
- package/src/dataTableListQuery.test.ts +220 -0
- package/src/dataTableListQuery.ts +201 -0
- package/src/index.tsx +21 -1
- package/src/lazyBoundaries/heavyOptionalExports.tsx +28 -0
- package/src/login/__snapshots__/LoginScreen.test.tsx.snap +22 -0
- package/src/markdownEmbeds.test.ts +53 -0
- package/src/markdownEmbeds.ts +62 -0
- package/src/pdfHtmlTemplate.test.ts +119 -0
- package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +22 -0
- package/src/testing/resolveTestId.test.ts +3 -0
- package/src/testing/resolveTestId.ts +1 -0
- package/src/testing/types.ts +3 -0
- package/src/textFieldOscillationGuard.test.ts +63 -0
- package/src/textFieldOscillationGuard.ts +89 -0
- package/src/types/react-native-markdown-display.d.ts +6 -0
- package/src/types/react-native-swiper-flatlist.d.ts +5 -5
- package/src/useAcknowledgeAnnouncement.test.ts +223 -0
- package/src/useAcknowledgeAnnouncement.ts +166 -0
- package/src/useAnnouncements.test.ts +226 -0
- package/src/useAnnouncements.ts +150 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type {FC, ReactNode} from "react";
|
|
2
|
+
import {Pressable, View} from "react-native";
|
|
3
|
+
|
|
4
|
+
import {Badge} from "./Badge";
|
|
5
|
+
import {Icon} from "./Icon";
|
|
6
|
+
|
|
7
|
+
export interface NotificationBellBadgeRenderProps {
|
|
8
|
+
testID: string;
|
|
9
|
+
unreadCount: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface NotificationBellIconRenderProps {
|
|
13
|
+
testID: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface NotificationBellProps {
|
|
17
|
+
onPress: () => void;
|
|
18
|
+
renderBadge?: (props: NotificationBellBadgeRenderProps) => ReactNode;
|
|
19
|
+
renderIcon?: (props: NotificationBellIconRenderProps) => ReactNode;
|
|
20
|
+
testID?: string;
|
|
21
|
+
unreadCount: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Tap target size. Also reserves room for the badge so it never needs negative
|
|
26
|
+
* offsets, which an ancestor with clipped overflow would slice off.
|
|
27
|
+
*/
|
|
28
|
+
const BELL_SIZE = 40;
|
|
29
|
+
|
|
30
|
+
export const NotificationBell: FC<NotificationBellProps> = ({
|
|
31
|
+
onPress,
|
|
32
|
+
renderBadge,
|
|
33
|
+
renderIcon,
|
|
34
|
+
testID = "notification-bell",
|
|
35
|
+
unreadCount,
|
|
36
|
+
}) => {
|
|
37
|
+
const showBadge = unreadCount > 0;
|
|
38
|
+
const unreadLabel =
|
|
39
|
+
unreadCount === 1 ? "1 unread notification" : `${unreadCount} unread notifications`;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<View style={{height: BELL_SIZE, position: "relative", width: BELL_SIZE}} testID={testID}>
|
|
43
|
+
<Pressable
|
|
44
|
+
accessibilityHint="Opens your notification inbox"
|
|
45
|
+
accessibilityLabel={showBadge ? `Notifications, ${unreadLabel}` : "Notifications"}
|
|
46
|
+
accessibilityRole="button"
|
|
47
|
+
onPress={onPress}
|
|
48
|
+
style={{alignItems: "center", flex: 1, justifyContent: "center"}}
|
|
49
|
+
testID={`${testID}-button`}
|
|
50
|
+
>
|
|
51
|
+
{renderIcon ? (
|
|
52
|
+
renderIcon({testID: `${testID}-icon`})
|
|
53
|
+
) : (
|
|
54
|
+
<Icon iconName="bell" size="md" testID={`${testID}-icon`} />
|
|
55
|
+
)}
|
|
56
|
+
</Pressable>
|
|
57
|
+
{showBadge ? (
|
|
58
|
+
<View
|
|
59
|
+
style={{pointerEvents: "none", position: "absolute", right: 0, top: 0}}
|
|
60
|
+
testID={`${testID}-badge-container`}
|
|
61
|
+
>
|
|
62
|
+
{renderBadge ? (
|
|
63
|
+
renderBadge({testID: `${testID}-badge`, unreadCount})
|
|
64
|
+
) : (
|
|
65
|
+
<Badge
|
|
66
|
+
maxValue={99}
|
|
67
|
+
status="error"
|
|
68
|
+
testID={`${testID}-badge`}
|
|
69
|
+
value={unreadCount}
|
|
70
|
+
variant="numberOnly"
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
</View>
|
|
74
|
+
) : null}
|
|
75
|
+
</View>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {describe, it} from "bun:test";
|
|
2
|
+
import {fireEvent} from "@testing-library/react-native";
|
|
3
|
+
import {assert} from "chai";
|
|
4
|
+
|
|
5
|
+
import {NotificationInbox, type NotificationInboxItem} from "./NotificationInbox";
|
|
6
|
+
import {renderWithTheme} from "./test-utils";
|
|
7
|
+
|
|
8
|
+
const items: NotificationInboxItem[] = [
|
|
9
|
+
{
|
|
10
|
+
body: "Unread body",
|
|
11
|
+
created: "2026-09-10T12:00:00.000Z",
|
|
12
|
+
href: "/todos",
|
|
13
|
+
id: "n1",
|
|
14
|
+
title: "Unread",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
body: "Read body",
|
|
18
|
+
created: "2026-09-09T12:00:00.000Z",
|
|
19
|
+
id: "n2",
|
|
20
|
+
readAt: "2026-09-09T13:00:00.000Z",
|
|
21
|
+
title: "Read",
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
describe("NotificationInbox", () => {
|
|
26
|
+
it("fires onOpen with the tapped item", () => {
|
|
27
|
+
let opened: NotificationInboxItem | undefined;
|
|
28
|
+
const {getByTestId} = renderWithTheme(
|
|
29
|
+
<NotificationInbox
|
|
30
|
+
items={items}
|
|
31
|
+
onDismiss={() => {}}
|
|
32
|
+
onMarkRead={() => {}}
|
|
33
|
+
onMarkUnread={() => {}}
|
|
34
|
+
onOpen={(item) => {
|
|
35
|
+
opened = item;
|
|
36
|
+
}}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
fireEvent.press(getByTestId("notification-inbox-open-n1"));
|
|
40
|
+
assert.equal(opened?.id, "n1");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("fires dismiss and mark-read callbacks", () => {
|
|
44
|
+
let dismissed: NotificationInboxItem | undefined;
|
|
45
|
+
let markedRead: NotificationInboxItem | undefined;
|
|
46
|
+
const {getByTestId} = renderWithTheme(
|
|
47
|
+
<NotificationInbox
|
|
48
|
+
items={items}
|
|
49
|
+
onDismiss={(item) => {
|
|
50
|
+
dismissed = item;
|
|
51
|
+
}}
|
|
52
|
+
onMarkRead={(item) => {
|
|
53
|
+
markedRead = item;
|
|
54
|
+
}}
|
|
55
|
+
onMarkUnread={() => {}}
|
|
56
|
+
onOpen={() => {}}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
fireEvent.press(getByTestId("notification-inbox-dismiss-n1"));
|
|
60
|
+
fireEvent.press(getByTestId("notification-inbox-mark-read-n1"));
|
|
61
|
+
assert.equal(dismissed?.id, "n1");
|
|
62
|
+
assert.equal(markedRead?.id, "n1");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("fires mark-unread for a read item", () => {
|
|
66
|
+
let markedUnread: NotificationInboxItem | undefined;
|
|
67
|
+
const {getByTestId} = renderWithTheme(
|
|
68
|
+
<NotificationInbox
|
|
69
|
+
items={items}
|
|
70
|
+
onDismiss={() => {}}
|
|
71
|
+
onMarkRead={() => {}}
|
|
72
|
+
onMarkUnread={(item) => {
|
|
73
|
+
markedUnread = item;
|
|
74
|
+
}}
|
|
75
|
+
onOpen={() => {}}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
fireEvent.press(getByTestId("notification-inbox-mark-unread-n2"));
|
|
80
|
+
|
|
81
|
+
assert.equal(markedUnread?.id, "n2");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("labels archived items and hides mutation actions", () => {
|
|
85
|
+
const archivedItem: NotificationInboxItem = {
|
|
86
|
+
...items[1],
|
|
87
|
+
archived: true,
|
|
88
|
+
id: "archived",
|
|
89
|
+
};
|
|
90
|
+
const {getByTestId, getByText, queryByTestId} = renderWithTheme(
|
|
91
|
+
<NotificationInbox
|
|
92
|
+
items={[archivedItem]}
|
|
93
|
+
onDismiss={() => {}}
|
|
94
|
+
onMarkRead={() => {}}
|
|
95
|
+
onMarkUnread={() => {}}
|
|
96
|
+
onOpen={() => {}}
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
assert.isOk(getByTestId("notification-inbox-item-archived"));
|
|
101
|
+
assert.isOk(getByText("Archived"));
|
|
102
|
+
assert.isNull(queryByTestId("notification-inbox-dismiss-archived"));
|
|
103
|
+
assert.isNull(queryByTestId("notification-inbox-mark-unread-archived"));
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("shows loading and empty states", () => {
|
|
107
|
+
const loading = renderWithTheme(
|
|
108
|
+
<NotificationInbox
|
|
109
|
+
isLoading
|
|
110
|
+
items={[]}
|
|
111
|
+
onDismiss={() => {}}
|
|
112
|
+
onMarkRead={() => {}}
|
|
113
|
+
onMarkUnread={() => {}}
|
|
114
|
+
onOpen={() => {}}
|
|
115
|
+
/>
|
|
116
|
+
);
|
|
117
|
+
assert.isOk(loading.getByTestId("notification-inbox-loading"));
|
|
118
|
+
|
|
119
|
+
const empty = renderWithTheme(
|
|
120
|
+
<NotificationInbox
|
|
121
|
+
items={[]}
|
|
122
|
+
onDismiss={() => {}}
|
|
123
|
+
onMarkRead={() => {}}
|
|
124
|
+
onMarkUnread={() => {}}
|
|
125
|
+
onOpen={() => {}}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
assert.isOk(empty.getByTestId("notification-inbox-empty"));
|
|
129
|
+
});
|
|
130
|
+
});
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import {DateTime} from "luxon";
|
|
2
|
+
import type {FC} from "react";
|
|
3
|
+
import {Pressable} from "react-native";
|
|
4
|
+
|
|
5
|
+
import {Box} from "./Box";
|
|
6
|
+
import {Heading} from "./Heading";
|
|
7
|
+
import {Spinner} from "./Spinner";
|
|
8
|
+
import {Text} from "./Text";
|
|
9
|
+
|
|
10
|
+
export interface NotificationInboxItem {
|
|
11
|
+
archived?: boolean;
|
|
12
|
+
body: string;
|
|
13
|
+
created?: string;
|
|
14
|
+
href?: string;
|
|
15
|
+
id: string;
|
|
16
|
+
kind?: string;
|
|
17
|
+
readAt?: string | null;
|
|
18
|
+
title: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface NotificationInboxProps {
|
|
22
|
+
isLoading?: boolean;
|
|
23
|
+
items: NotificationInboxItem[];
|
|
24
|
+
onDismiss: (item: NotificationInboxItem) => void;
|
|
25
|
+
onMarkRead: (item: NotificationInboxItem) => void;
|
|
26
|
+
onMarkUnread: (item: NotificationInboxItem) => void;
|
|
27
|
+
onOpen: (item: NotificationInboxItem) => void;
|
|
28
|
+
testID?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const formatTimestamp = (created?: string): string => {
|
|
32
|
+
if (!created) {
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
const parsed = DateTime.fromISO(created);
|
|
36
|
+
if (!parsed.isValid) {
|
|
37
|
+
return "";
|
|
38
|
+
}
|
|
39
|
+
return parsed.toRelative() ?? parsed.toLocaleString(DateTime.DATETIME_MED);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const isUnread = (item: NotificationInboxItem): boolean => !item.readAt;
|
|
43
|
+
|
|
44
|
+
export const NotificationInbox: FC<NotificationInboxProps> = ({
|
|
45
|
+
isLoading = false,
|
|
46
|
+
items,
|
|
47
|
+
onDismiss,
|
|
48
|
+
onMarkRead,
|
|
49
|
+
onMarkUnread,
|
|
50
|
+
onOpen,
|
|
51
|
+
testID = "notification-inbox",
|
|
52
|
+
}) => {
|
|
53
|
+
if (isLoading) {
|
|
54
|
+
return (
|
|
55
|
+
<Box alignItems="center" paddingY={6} testID={`${testID}-loading`}>
|
|
56
|
+
<Spinner />
|
|
57
|
+
</Box>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (items.length === 0) {
|
|
62
|
+
return (
|
|
63
|
+
<Box paddingY={4} testID={`${testID}-empty`}>
|
|
64
|
+
<Text color="secondaryLight">You are all caught up.</Text>
|
|
65
|
+
</Box>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Box gap={3} testID={`${testID}-list`}>
|
|
71
|
+
{items.map((item) => {
|
|
72
|
+
const unread = isUnread(item);
|
|
73
|
+
const isArchived = item.archived === true;
|
|
74
|
+
return (
|
|
75
|
+
<Box
|
|
76
|
+
border="default"
|
|
77
|
+
color={unread ? "secondaryLight" : "base"}
|
|
78
|
+
gap={2}
|
|
79
|
+
key={item.id}
|
|
80
|
+
padding={3}
|
|
81
|
+
rounding="md"
|
|
82
|
+
testID={`${testID}-item-${item.id}`}
|
|
83
|
+
>
|
|
84
|
+
<Box alignItems="start" direction="row" justifyContent="between">
|
|
85
|
+
<Box flex="grow" gap={1}>
|
|
86
|
+
<Box alignItems="center" direction="row" gap={2}>
|
|
87
|
+
<Heading size="sm">{item.title}</Heading>
|
|
88
|
+
{isArchived ? <Text color="secondaryLight">Archived</Text> : null}
|
|
89
|
+
</Box>
|
|
90
|
+
{item.created ? (
|
|
91
|
+
<Text color="secondaryLight" size="sm">
|
|
92
|
+
{formatTimestamp(item.created)}
|
|
93
|
+
</Text>
|
|
94
|
+
) : null}
|
|
95
|
+
</Box>
|
|
96
|
+
{!isArchived ? (
|
|
97
|
+
<Pressable
|
|
98
|
+
accessibilityLabel="Dismiss notification"
|
|
99
|
+
onPress={() => {
|
|
100
|
+
onDismiss(item);
|
|
101
|
+
}}
|
|
102
|
+
testID={`${testID}-dismiss-${item.id}`}
|
|
103
|
+
>
|
|
104
|
+
<Text color="secondaryLight">Dismiss</Text>
|
|
105
|
+
</Pressable>
|
|
106
|
+
) : null}
|
|
107
|
+
</Box>
|
|
108
|
+
<Pressable
|
|
109
|
+
onPress={() => {
|
|
110
|
+
onOpen(item);
|
|
111
|
+
}}
|
|
112
|
+
testID={`${testID}-open-${item.id}`}
|
|
113
|
+
>
|
|
114
|
+
<Text>{item.body}</Text>
|
|
115
|
+
</Pressable>
|
|
116
|
+
{!isArchived ? (
|
|
117
|
+
<Box direction="row" gap={2} wrap>
|
|
118
|
+
{unread ? (
|
|
119
|
+
<Pressable
|
|
120
|
+
onPress={() => {
|
|
121
|
+
onMarkRead(item);
|
|
122
|
+
}}
|
|
123
|
+
testID={`${testID}-mark-read-${item.id}`}
|
|
124
|
+
>
|
|
125
|
+
<Text color="link">Mark read</Text>
|
|
126
|
+
</Pressable>
|
|
127
|
+
) : (
|
|
128
|
+
<Pressable
|
|
129
|
+
onPress={() => {
|
|
130
|
+
onMarkUnread(item);
|
|
131
|
+
}}
|
|
132
|
+
testID={`${testID}-mark-unread-${item.id}`}
|
|
133
|
+
>
|
|
134
|
+
<Text color="link">Mark unread</Text>
|
|
135
|
+
</Pressable>
|
|
136
|
+
)}
|
|
137
|
+
</Box>
|
|
138
|
+
) : null}
|
|
139
|
+
</Box>
|
|
140
|
+
);
|
|
141
|
+
})}
|
|
142
|
+
</Box>
|
|
143
|
+
);
|
|
144
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {describe, it} from "bun:test";
|
|
2
|
+
import {fireEvent} from "@testing-library/react-native";
|
|
3
|
+
import {assert} from "chai";
|
|
4
|
+
|
|
5
|
+
import {NotificationPreferences} from "./NotificationPreferences";
|
|
6
|
+
import {renderWithTheme} from "./test-utils";
|
|
7
|
+
|
|
8
|
+
describe("NotificationPreferences", () => {
|
|
9
|
+
it("calls onChange when mail is toggled", () => {
|
|
10
|
+
let changedChannel: string | undefined;
|
|
11
|
+
let changedValue: boolean | undefined;
|
|
12
|
+
const {getByTestId} = renderWithTheme(
|
|
13
|
+
<NotificationPreferences
|
|
14
|
+
onChange={(channel, value) => {
|
|
15
|
+
changedChannel = channel;
|
|
16
|
+
changedValue = value;
|
|
17
|
+
}}
|
|
18
|
+
preferences={{inapp: true, mail: true, push: true, sms: true}}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
fireEvent.press(getByTestId("notification-preferences-mail.switch"));
|
|
22
|
+
assert.equal(changedChannel, "mail");
|
|
23
|
+
assert.equal(changedValue, false);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type {FC} from "react";
|
|
2
|
+
|
|
3
|
+
import {BooleanField} from "./BooleanField";
|
|
4
|
+
import {Box} from "./Box";
|
|
5
|
+
import {Heading} from "./Heading";
|
|
6
|
+
import {Text} from "./Text";
|
|
7
|
+
|
|
8
|
+
export interface NotificationPreferencesState {
|
|
9
|
+
inapp: boolean;
|
|
10
|
+
mail: boolean;
|
|
11
|
+
push: boolean;
|
|
12
|
+
sms: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type NotificationPreferenceChannel = keyof NotificationPreferencesState;
|
|
16
|
+
|
|
17
|
+
export interface NotificationPreferencesProps {
|
|
18
|
+
onChange: (channel: NotificationPreferenceChannel, value: boolean) => void;
|
|
19
|
+
preferences: NotificationPreferencesState;
|
|
20
|
+
testID?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const CHANNEL_COPY: Record<NotificationPreferenceChannel, {description: string; title: string}> = {
|
|
24
|
+
inapp: {
|
|
25
|
+
description: "Show notifications inside the app inbox.",
|
|
26
|
+
title: "In-app inbox",
|
|
27
|
+
},
|
|
28
|
+
mail: {
|
|
29
|
+
description: "Send notification email when a destination address is available.",
|
|
30
|
+
title: "Email",
|
|
31
|
+
},
|
|
32
|
+
push: {
|
|
33
|
+
description: "Send push notifications to registered devices.",
|
|
34
|
+
title: "Push",
|
|
35
|
+
},
|
|
36
|
+
sms: {
|
|
37
|
+
description: "Send SMS when a phone number is available.",
|
|
38
|
+
title: "SMS",
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const NotificationPreferences: FC<NotificationPreferencesProps> = ({
|
|
43
|
+
onChange,
|
|
44
|
+
preferences,
|
|
45
|
+
testID = "notification-preferences",
|
|
46
|
+
}) => {
|
|
47
|
+
return (
|
|
48
|
+
<Box gap={4} testID={testID}>
|
|
49
|
+
<Box gap={1}>
|
|
50
|
+
<Heading size="lg">Notification preferences</Heading>
|
|
51
|
+
<Text color="secondaryLight">
|
|
52
|
+
Choose which channels can deliver notifications from this app.
|
|
53
|
+
</Text>
|
|
54
|
+
</Box>
|
|
55
|
+
{(Object.keys(CHANNEL_COPY) as NotificationPreferenceChannel[]).map((channel) => {
|
|
56
|
+
const copy = CHANNEL_COPY[channel];
|
|
57
|
+
return (
|
|
58
|
+
<Box gap={1} key={channel}>
|
|
59
|
+
<BooleanField
|
|
60
|
+
onChange={(value) => {
|
|
61
|
+
onChange(channel, value);
|
|
62
|
+
}}
|
|
63
|
+
testID={`${testID}-${channel}`}
|
|
64
|
+
title={copy.title}
|
|
65
|
+
value={preferences[channel]}
|
|
66
|
+
/>
|
|
67
|
+
<Text color="secondaryLight" size="sm">
|
|
68
|
+
{copy.description}
|
|
69
|
+
</Text>
|
|
70
|
+
</Box>
|
|
71
|
+
);
|
|
72
|
+
})}
|
|
73
|
+
</Box>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import {describe, expect, it} from "bun:test";
|
|
2
|
+
import {resolve} from "node:path";
|
|
2
3
|
|
|
3
4
|
import {
|
|
4
5
|
AIRequestExplorer,
|
|
5
6
|
Button,
|
|
6
7
|
ConsentNavigator,
|
|
8
|
+
DashboardGrid,
|
|
7
9
|
DraggableList,
|
|
8
10
|
EmojiSelector,
|
|
9
11
|
GPTChat,
|
|
12
|
+
LineChart,
|
|
10
13
|
MarkdownEditor,
|
|
11
14
|
} from "@terreno/ui";
|
|
12
15
|
import {Box} from "@terreno/ui/Box";
|
|
13
16
|
import EmojiSelectorSubpath from "@terreno/ui/EmojiSelector";
|
|
14
17
|
import {GPTChat as GPTChatSubpath} from "@terreno/ui/GPTChat";
|
|
18
|
+
import {LineChart as LineChartSubpath} from "@terreno/ui/LineChart";
|
|
15
19
|
import {MarkdownView} from "@terreno/ui/MarkdownView";
|
|
16
20
|
|
|
21
|
+
import {measureImportGraph} from "./benchmarks/importGraph";
|
|
17
22
|
import {Categories} from "./emojiCategories";
|
|
18
23
|
import {EmojiSelector as LazyEmojiSelector} from "./lazyBoundaries/heavyOptionalExports";
|
|
19
24
|
|
|
@@ -26,6 +31,7 @@ const ROOT_IMPORT_PATHS = [
|
|
|
26
31
|
"@terreno/ui/GPTChat",
|
|
27
32
|
"@terreno/ui/EmojiSelector",
|
|
28
33
|
"@terreno/ui/MarkdownView",
|
|
34
|
+
"@terreno/ui/LineChart",
|
|
29
35
|
];
|
|
30
36
|
|
|
31
37
|
describe("root import compatibility", () => {
|
|
@@ -38,6 +44,20 @@ describe("root import compatibility", () => {
|
|
|
38
44
|
expect(GPTChatSubpath).toBeTruthy();
|
|
39
45
|
expect(EmojiSelectorSubpath).toBeTruthy();
|
|
40
46
|
expect(MarkdownView).toBeTruthy();
|
|
47
|
+
expect(LineChartSubpath).toBeTruthy();
|
|
48
|
+
expect(DashboardGrid).toBeTruthy();
|
|
49
|
+
expect(LineChart).toBeTruthy();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("keeps chart implementations off the cold root graph", () => {
|
|
53
|
+
const graph = measureImportGraph(resolve(import.meta.dir, "./index.tsx"));
|
|
54
|
+
const modulePaths = graph.modulePaths.join("\n");
|
|
55
|
+
|
|
56
|
+
expect(modulePaths.includes("/LineChart.tsx")).toBe(false);
|
|
57
|
+
expect(modulePaths.includes("/BarChart.tsx")).toBe(false);
|
|
58
|
+
expect(modulePaths.includes("/AreaChart.tsx")).toBe(false);
|
|
59
|
+
expect(modulePaths.includes("/DonutChart.tsx")).toBe(false);
|
|
60
|
+
expect(modulePaths.includes("/DashboardGrid.tsx")).toBe(true);
|
|
41
61
|
});
|
|
42
62
|
|
|
43
63
|
it("exposes lazy root exports for measured heavy optional widgets", () => {
|