@terreno/ui 0.0.16 → 0.0.18

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 (46) hide show
  1. package/dist/Button.js +7 -9
  2. package/dist/Button.js.map +1 -1
  3. package/dist/Common.d.ts +39 -0
  4. package/dist/TerrenoProvider.js +1 -1
  5. package/dist/TerrenoProvider.js.map +1 -1
  6. package/dist/Toast.js +2 -3
  7. package/dist/Toast.js.map +1 -1
  8. package/dist/ToastNotifications.d.ts +144 -0
  9. package/dist/ToastNotifications.js +387 -0
  10. package/dist/ToastNotifications.js.map +1 -0
  11. package/dist/UserInactivity.d.ts +28 -0
  12. package/dist/UserInactivity.js +100 -0
  13. package/dist/UserInactivity.js.map +1 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +1 -0
  16. package/dist/index.js.map +1 -1
  17. package/package.json +1 -2
  18. package/src/Button.tsx +20 -37
  19. package/src/Common.ts +45 -0
  20. package/src/DateTimeActionSheet.test.tsx +53 -4
  21. package/src/MobileAddressAutoComplete.test.tsx +47 -4
  22. package/src/ModalSheet.test.tsx +37 -5
  23. package/src/PickerSelect.test.tsx +41 -5
  24. package/src/Signature.test.tsx +21 -4
  25. package/src/SignatureField.test.tsx +49 -5
  26. package/src/SplitPage.test.tsx +71 -4
  27. package/src/TerrenoProvider.tsx +1 -1
  28. package/src/Toast.tsx +2 -3
  29. package/src/ToastNotifications.test.tsx +645 -0
  30. package/src/ToastNotifications.tsx +746 -0
  31. package/src/UnifiedAddressAutoComplete.test.tsx +43 -5
  32. package/src/UserInactivity.test.tsx +96 -0
  33. package/src/UserInactivity.tsx +129 -0
  34. package/src/WebAddressAutocomplete.test.tsx +22 -4
  35. package/src/__snapshots__/Button.test.tsx.snap +0 -347
  36. package/src/__snapshots__/DateTimeActionSheet.test.tsx.snap +11 -0
  37. package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +230 -0
  38. package/src/__snapshots__/ModalSheet.test.tsx.snap +37 -0
  39. package/src/__snapshots__/PickerSelect.test.tsx.snap +798 -11
  40. package/src/__snapshots__/Signature.test.tsx.snap +67 -0
  41. package/src/__snapshots__/SignatureField.test.tsx.snap +129 -21
  42. package/src/__snapshots__/SplitPage.test.tsx.snap +686 -0
  43. package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +377 -0
  44. package/src/__snapshots__/UserInactivity.test.tsx.snap +108 -0
  45. package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +238 -0
  46. package/src/index.tsx +1 -0
package/src/Button.tsx CHANGED
@@ -1,40 +1,18 @@
1
1
  import FontAwesome6 from "@expo/vector-icons/FontAwesome6";
2
2
  import debounce from "lodash/debounce";
3
- import {type FC, useMemo, useState} from "react";
3
+ import {type FC, lazy, Suspense, useMemo, useState} from "react";
4
4
  import {ActivityIndicator, Pressable, Text, View} from "react-native";
5
5
 
6
6
  import {Box} from "./Box";
7
7
  import type {ButtonProps} from "./Common";
8
8
  import {isMobileDevice} from "./MediaQuery";
9
- import {Modal} from "./Modal";
10
9
  import {useTheme} from "./Theme";
11
10
  import {Tooltip} from "./Tooltip";
12
11
  import {Unifier} from "./Unifier";
13
12
  import {isNative} from "./Utilities";
14
13
 
15
- const ConfirmationModal: FC<{
16
- visible: boolean;
17
- title: string;
18
- subtitle?: string;
19
- text: string;
20
- onConfirm: () => void;
21
- onCancel: () => void;
22
- }> = ({visible, title, subtitle, text, onConfirm, onCancel}) => {
23
- return (
24
- <Modal
25
- onDismiss={onCancel}
26
- primaryButtonOnClick={onConfirm}
27
- primaryButtonText="Confirm"
28
- secondaryButtonOnClick={onCancel}
29
- secondaryButtonText="Cancel"
30
- subtitle={subtitle}
31
- title={title}
32
- visible={visible}
33
- >
34
- <Text>{text}</Text>
35
- </Modal>
36
- );
37
- };
14
+ // Lazy load Modal to break the circular dependency: Modal -> Button -> Modal
15
+ const LazyModal = lazy(() => import("./Modal").then((module) => ({default: module.Modal})));
38
16
 
39
17
  const ButtonComponent: FC<ButtonProps> = ({
40
18
  confirmationText = "Are you sure you want to continue?",
@@ -159,18 +137,23 @@ const ButtonComponent: FC<ButtonProps> = ({
159
137
  </Box>
160
138
  )}
161
139
  </View>
162
- {withConfirmation && (
163
- <ConfirmationModal
164
- onCancel={() => setShowConfirmation(false)}
165
- onConfirm={async () => {
166
- await onClick();
167
- setShowConfirmation(false);
168
- }}
169
- subtitle={modalSubTitle}
170
- text={confirmationText}
171
- title={modalTitle}
172
- visible={showConfirmation}
173
- />
140
+ {withConfirmation && showConfirmation && (
141
+ <Suspense fallback={null}>
142
+ <LazyModal
143
+ onDismiss={() => setShowConfirmation(false)}
144
+ primaryButtonOnClick={async () => {
145
+ await onClick();
146
+ setShowConfirmation(false);
147
+ }}
148
+ primaryButtonText="Confirm"
149
+ secondaryButtonOnClick={() => setShowConfirmation(false)}
150
+ secondaryButtonText="Cancel"
151
+ subtitle={modalSubTitle}
152
+ text={confirmationText}
153
+ title={modalTitle}
154
+ visible={showConfirmation}
155
+ />
156
+ </Suspense>
174
157
  )}
175
158
  </Pressable>
176
159
  );
package/src/Common.ts CHANGED
@@ -2785,3 +2785,48 @@ export interface SliderProps extends HelperTextProps, ErrorTextProps {
2785
2785
  */
2786
2786
  valueMapping?: ValueMappingItem[];
2787
2787
  }
2788
+
2789
+ export interface UserInactivityProps {
2790
+ /**
2791
+ * Children components to embed inside UserInactivity's View.
2792
+ * If any children component is pressed, `onAction` is called after
2793
+ * `timeForInactivity` milliseconds.
2794
+ */
2795
+ children: React.ReactNode;
2796
+
2797
+ /**
2798
+ * If it's explicitly set to `true` after the component has already been initialized,
2799
+ * the timer restarts and the view is considered active until the new timer expires.
2800
+ * @default true
2801
+ */
2802
+ isActive?: boolean;
2803
+
2804
+ /**
2805
+ * Callback triggered anytime UserInactivity's View isn't touched for more than
2806
+ * `timeForInactivity` milliseconds.
2807
+ * The `active` argument is true if and only if the View wasn't touched for more
2808
+ * than `timeForInactivity` milliseconds.
2809
+ */
2810
+ onAction: (active: boolean) => void;
2811
+
2812
+ /**
2813
+ * If set to true, the timer is not reset when the keyboard appears
2814
+ * or disappears.
2815
+ * @default false
2816
+ */
2817
+ skipKeyboard?: boolean;
2818
+
2819
+ /**
2820
+ * Optional custom style for UserInactivity's View.
2821
+ * @default { flex: 1 }
2822
+ */
2823
+ style?: StyleProp<ViewStyle>;
2824
+
2825
+ /**
2826
+ * Number of milliseconds after which the view is considered inactive.
2827
+ * If it changed, the timer restarts and the view is considered active until
2828
+ * the new timer expires.
2829
+ * @default 10000
2830
+ */
2831
+ timeForInactivity?: number;
2832
+ }
@@ -1,16 +1,65 @@
1
1
  import {describe, expect, it} from "bun:test";
2
2
 
3
3
  import {DateTimeActionSheet} from "./DateTimeActionSheet";
4
+ import {renderWithTheme} from "./test-utils";
5
+
6
+ // Note: @react-native-picker/picker, react-native-calendars, and expo-localization
7
+ // are mocked globally in bunSetup.ts
4
8
 
5
9
  describe("DateTimeActionSheet", () => {
6
- // DateTimeActionSheet uses react-native-calendars and @react-native-picker/picker
7
- // which don't work in the test environment
8
- it.skip("renders correctly (skipped - uses native picker and calendar)", () => {
9
- expect(DateTimeActionSheet).toBeDefined();
10
+ const defaultProps = {
11
+ onChange: () => {},
12
+ onDismiss: () => {},
13
+ visible: true,
14
+ };
15
+
16
+ it("renders correctly with datetime type", () => {
17
+ const {toJSON} = renderWithTheme(
18
+ <DateTimeActionSheet {...defaultProps} type="datetime" value="2024-01-15T10:30:00.000Z" />
19
+ );
20
+ expect(toJSON()).toMatchSnapshot();
10
21
  });
11
22
 
12
23
  it("component is defined", () => {
13
24
  expect(DateTimeActionSheet).toBeDefined();
14
25
  expect(typeof DateTimeActionSheet).toBe("function");
15
26
  });
27
+
28
+ it("renders correctly with date type", () => {
29
+ const {toJSON} = renderWithTheme(
30
+ <DateTimeActionSheet {...defaultProps} type="date" value="2024-01-15T00:00:00.000Z" />
31
+ );
32
+ expect(toJSON()).toMatchSnapshot();
33
+ });
34
+
35
+ it("renders correctly with time type", () => {
36
+ const {toJSON} = renderWithTheme(
37
+ <DateTimeActionSheet {...defaultProps} type="time" value="2024-01-15T10:30:00.000Z" />
38
+ );
39
+ expect(toJSON()).toMatchSnapshot();
40
+ });
41
+
42
+ it("renders correctly when not visible", () => {
43
+ const {toJSON} = renderWithTheme(
44
+ <DateTimeActionSheet
45
+ {...defaultProps}
46
+ type="datetime"
47
+ value="2024-01-15T10:30:00.000Z"
48
+ visible={false}
49
+ />
50
+ );
51
+ expect(toJSON()).toMatchSnapshot();
52
+ });
53
+
54
+ it("renders with custom timezone", () => {
55
+ const {toJSON} = renderWithTheme(
56
+ <DateTimeActionSheet
57
+ {...defaultProps}
58
+ timezone="America/Los_Angeles"
59
+ type="datetime"
60
+ value="2024-01-15T10:30:00.000Z"
61
+ />
62
+ );
63
+ expect(toJSON()).toMatchSnapshot();
64
+ });
16
65
  });
@@ -1,15 +1,58 @@
1
- import {describe, expect, it} from "bun:test";
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import {forwardRef} from "react";
3
+ import {Text, View} from "react-native";
2
4
 
3
5
  import {MobileAddressAutocomplete} from "./MobileAddressAutoComplete";
6
+ import {renderWithTheme} from "./test-utils";
7
+
8
+ // Mock react-native-google-places-autocomplete
9
+ mock.module("react-native-google-places-autocomplete", () => ({
10
+ GooglePlacesAutocomplete: forwardRef(({placeholder}: any, ref) => (
11
+ <View ref={ref as any} testID="google-places-autocomplete">
12
+ <Text>{placeholder}</Text>
13
+ </View>
14
+ )),
15
+ }));
4
16
 
5
17
  describe("MobileAddressAutocomplete", () => {
6
- // MobileAddressAutocomplete uses Google Places API and complex native interactions
7
- it.skip("renders correctly (skipped - uses Google Places API)", () => {
8
- expect(MobileAddressAutocomplete).toBeDefined();
18
+ const defaultProps = {
19
+ handleAddressChange: () => {},
20
+ handleAutoCompleteChange: () => {},
21
+ inputValue: "",
22
+ };
23
+
24
+ it("renders correctly with Google API key", () => {
25
+ const {toJSON} = renderWithTheme(
26
+ <MobileAddressAutocomplete {...defaultProps} googleMapsApiKey="test-api-key" />
27
+ );
28
+ expect(toJSON()).toMatchSnapshot();
9
29
  });
10
30
 
11
31
  it("component is defined", () => {
12
32
  expect(MobileAddressAutocomplete).toBeDefined();
13
33
  expect(typeof MobileAddressAutocomplete).toBe("function");
14
34
  });
35
+
36
+ it("renders TextField fallback without Google API key", () => {
37
+ const {toJSON} = renderWithTheme(<MobileAddressAutocomplete {...defaultProps} />);
38
+ expect(toJSON()).toMatchSnapshot();
39
+ });
40
+
41
+ it("renders disabled state", () => {
42
+ const {toJSON} = renderWithTheme(
43
+ <MobileAddressAutocomplete {...defaultProps} disabled googleMapsApiKey="test-api-key" />
44
+ );
45
+ expect(toJSON()).toMatchSnapshot();
46
+ });
47
+
48
+ it("renders with input value", () => {
49
+ const {toJSON} = renderWithTheme(
50
+ <MobileAddressAutocomplete
51
+ {...defaultProps}
52
+ googleMapsApiKey="test-api-key"
53
+ inputValue="123 Main St"
54
+ />
55
+ );
56
+ expect(toJSON()).toMatchSnapshot();
57
+ });
15
58
  });
@@ -1,12 +1,32 @@
1
- import {describe, expect, it} from "bun:test";
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import {forwardRef, useRef} from "react";
3
+ import {Text, View} from "react-native";
2
4
 
3
5
  import {SimpleContent, useCombinedRefs} from "./ModalSheet";
6
+ import {renderWithTheme} from "./test-utils";
7
+
8
+ // Mock react-native-modalize
9
+ mock.module("react-native-modalize", () => ({
10
+ Modalize: forwardRef(({children}: {children: React.ReactNode}, ref) => (
11
+ <View ref={ref as any} testID="modalize">
12
+ {children}
13
+ </View>
14
+ )),
15
+ }));
16
+
17
+ // Mock react-native-portalize
18
+ mock.module("react-native-portalize", () => ({
19
+ Portal: ({children}: {children: React.ReactNode}) => <View testID="portal">{children}</View>,
20
+ }));
4
21
 
5
22
  describe("ModalSheet", () => {
6
- // ModalSheet uses react-native-modalize and react-native-portalize
7
- // which don't work in the test environment
8
- it.skip("renders correctly (skipped - uses react-native-modalize)", () => {
9
- expect(SimpleContent).toBeDefined();
23
+ it("renders correctly with children", () => {
24
+ const {toJSON} = renderWithTheme(
25
+ <SimpleContent>
26
+ <Text>Test Content</Text>
27
+ </SimpleContent>
28
+ );
29
+ expect(toJSON()).toMatchSnapshot();
10
30
  });
11
31
 
12
32
  it("SimpleContent is defined", () => {
@@ -17,4 +37,16 @@ describe("ModalSheet", () => {
17
37
  expect(useCombinedRefs).toBeDefined();
18
38
  expect(typeof useCombinedRefs).toBe("function");
19
39
  });
40
+
41
+ it("useCombinedRefs combines multiple refs", () => {
42
+ const TestComponent = () => {
43
+ const ref1 = useRef<View>(null);
44
+ const ref2 = useRef<View>(null);
45
+ const combinedRef = useCombinedRefs(ref1, ref2);
46
+ return <View ref={combinedRef} testID="combined-ref-view" />;
47
+ };
48
+
49
+ const {getByTestId} = renderWithTheme(<TestComponent />);
50
+ expect(getByTestId("combined-ref-view")).toBeTruthy();
51
+ });
20
52
  });
@@ -1,16 +1,52 @@
1
- import {describe, expect, it} from "bun:test";
1
+ import {describe, expect, it, mock} from "bun:test";
2
2
 
3
3
  import {RNPickerSelect} from "./PickerSelect";
4
+ import {renderWithTheme} from "./test-utils";
5
+
6
+ // Note: @react-native-picker/picker is mocked globally in bunSetup.ts
4
7
 
5
8
  describe("PickerSelect", () => {
6
- // PickerSelect uses @react-native-picker/picker which has internal issues
7
- // with the test renderer (TypeError: undefined is not an object evaluating 'item.key')
8
- it.skip("renders correctly (skipped - Picker component not supported in test environment)", () => {
9
- expect(RNPickerSelect).toBeDefined();
9
+ const defaultProps = {
10
+ items: [
11
+ {label: "Option 1", value: "1"},
12
+ {label: "Option 2", value: "2"},
13
+ {label: "Option 3", value: "3"},
14
+ ],
15
+ onValueChange: () => {},
16
+ placeholder: {label: "Select an option", value: ""},
17
+ };
18
+
19
+ it("renders correctly with default props", () => {
20
+ const {toJSON} = renderWithTheme(<RNPickerSelect {...defaultProps} />);
21
+ expect(toJSON()).toMatchSnapshot();
10
22
  });
11
23
 
12
24
  it("component is defined", () => {
13
25
  expect(RNPickerSelect).toBeDefined();
14
26
  expect(typeof RNPickerSelect).toBe("function");
15
27
  });
28
+
29
+ it("renders with selected value", () => {
30
+ const {toJSON} = renderWithTheme(<RNPickerSelect {...defaultProps} value="2" />);
31
+ expect(toJSON()).toMatchSnapshot();
32
+ });
33
+
34
+ it("renders disabled state", () => {
35
+ const {toJSON} = renderWithTheme(<RNPickerSelect {...defaultProps} disabled />);
36
+ expect(toJSON()).toMatchSnapshot();
37
+ });
38
+
39
+ it("renders without placeholder when placeholder is empty object", () => {
40
+ const {toJSON} = renderWithTheme(<RNPickerSelect {...defaultProps} placeholder={{}} />);
41
+ expect(toJSON()).toMatchSnapshot();
42
+ });
43
+
44
+ it("calls onValueChange when value changes", () => {
45
+ const mockOnValueChange = mock(() => {});
46
+ renderWithTheme(
47
+ <RNPickerSelect {...defaultProps} onValueChange={mockOnValueChange} value="1" />
48
+ );
49
+ // The component is rendered, onValueChange would be called on user interaction
50
+ expect(mockOnValueChange).toBeDefined();
51
+ });
16
52
  });
@@ -1,15 +1,32 @@
1
- import {describe, expect, it} from "bun:test";
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import {forwardRef} from "react";
3
+ import {View} from "react-native";
2
4
 
3
5
  import {Signature} from "./Signature";
6
+ import {renderWithTheme} from "./test-utils";
7
+
8
+ // Mock react-signature-canvas
9
+ mock.module("react-signature-canvas", () => ({
10
+ default: forwardRef(({backgroundColor}: any, ref) => (
11
+ <View ref={ref as any} style={{backgroundColor}} testID="signature-canvas" />
12
+ )),
13
+ }));
4
14
 
5
15
  describe("Signature", () => {
6
- // Signature uses react-signature-canvas which requires a canvas/DOM environment
7
- it.skip("renders correctly (skipped - requires canvas environment)", () => {
8
- expect(Signature).toBeDefined();
16
+ it("renders correctly", () => {
17
+ const mockOnChange = mock(() => {});
18
+ const {toJSON} = renderWithTheme(<Signature onChange={mockOnChange} />);
19
+ expect(toJSON()).toMatchSnapshot();
9
20
  });
10
21
 
11
22
  it("component is defined", () => {
12
23
  expect(Signature).toBeDefined();
13
24
  expect(typeof Signature).toBe("function");
14
25
  });
26
+
27
+ it("renders with clear button", () => {
28
+ const mockOnChange = mock(() => {});
29
+ const {getByText} = renderWithTheme(<Signature onChange={mockOnChange} />);
30
+ expect(getByText("Clear")).toBeTruthy();
31
+ });
15
32
  });
@@ -1,16 +1,60 @@
1
- import {describe, expect, it} from "bun:test";
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import {forwardRef} from "react";
3
+ import {View} from "react-native";
2
4
 
3
5
  import {SignatureField} from "./SignatureField";
6
+ import {renderWithTheme} from "./test-utils";
7
+
8
+ // Mock react-signature-canvas (used by Signature component)
9
+ mock.module("react-signature-canvas", () => ({
10
+ default: forwardRef(({backgroundColor}: any, ref) => (
11
+ <View ref={ref as any} style={{backgroundColor}} testID="signature-canvas" />
12
+ )),
13
+ }));
4
14
 
5
15
  describe("SignatureField", () => {
6
- // SignatureField uses react-signature-canvas which requires a canvas/DOM environment
7
- // that isn't available in the bun test environment
8
- it.skip("renders correctly (skipped - requires canvas environment)", () => {
9
- expect(SignatureField).toBeDefined();
16
+ const defaultProps = {
17
+ onChange: () => {},
18
+ };
19
+
20
+ it("renders correctly with default props", () => {
21
+ const {toJSON} = renderWithTheme(<SignatureField {...defaultProps} />);
22
+ expect(toJSON()).toMatchSnapshot();
10
23
  });
11
24
 
12
25
  it("component is defined", () => {
13
26
  expect(SignatureField).toBeDefined();
14
27
  expect(typeof SignatureField).toBe("function");
15
28
  });
29
+
30
+ it("renders with custom title", () => {
31
+ const {getByText} = renderWithTheme(<SignatureField {...defaultProps} title="Sign Here" />);
32
+ expect(getByText("Sign Here")).toBeTruthy();
33
+ });
34
+
35
+ it("renders disabled state with value", () => {
36
+ const {toJSON} = renderWithTheme(
37
+ <SignatureField
38
+ {...defaultProps}
39
+ disabled
40
+ disabledText="Signature captured"
41
+ value="data:image/png;base64,test"
42
+ />
43
+ );
44
+ expect(toJSON()).toMatchSnapshot();
45
+ });
46
+
47
+ it("renders disabled state without value", () => {
48
+ const {toJSON} = renderWithTheme(
49
+ <SignatureField {...defaultProps} disabled disabledText="Signature not available" />
50
+ );
51
+ expect(toJSON()).toMatchSnapshot();
52
+ });
53
+
54
+ it("renders with error text", () => {
55
+ const {getByText} = renderWithTheme(
56
+ <SignatureField {...defaultProps} errorText="Signature is required" />
57
+ );
58
+ expect(getByText("Signature is required")).toBeTruthy();
59
+ });
16
60
  });
@@ -1,15 +1,82 @@
1
- import {describe, expect, it} from "bun:test";
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import {View} from "react-native";
2
3
 
3
4
  import {SplitPage} from "./SplitPage";
5
+ import {renderWithTheme} from "./test-utils";
6
+
7
+ // Mock react-native-swiper-flatlist
8
+ mock.module("react-native-swiper-flatlist", () => ({
9
+ SwiperFlatList: ({children}: {children: React.ReactNode}) => (
10
+ <View testID="swiper-flatlist">{children}</View>
11
+ ),
12
+ }));
4
13
 
5
14
  describe("SplitPage", () => {
6
- // SplitPage uses react-native-swiper-flatlist and complex FlatList interactions
7
- it.skip("renders correctly (skipped - uses react-native-swiper-flatlist)", () => {
8
- expect(SplitPage).toBeDefined();
15
+ const defaultProps = {
16
+ listViewData: [
17
+ {id: "1", name: "Item 1"},
18
+ {id: "2", name: "Item 2"},
19
+ ],
20
+ renderListViewItem: ({item}: {item: {id: string; name: string}}) => (
21
+ <View testID={`item-${item.id}`} />
22
+ ),
23
+ };
24
+
25
+ it("renders correctly with renderContent", () => {
26
+ const {toJSON} = renderWithTheme(
27
+ <SplitPage
28
+ {...defaultProps}
29
+ renderContent={(selectedId) => <View testID={`content-${selectedId}`} />}
30
+ />
31
+ );
32
+ expect(toJSON()).toMatchSnapshot();
33
+ });
34
+
35
+ it("renders correctly with children", () => {
36
+ const {toJSON} = renderWithTheme(
37
+ <SplitPage {...defaultProps}>
38
+ <View testID="child-1" />
39
+ <View testID="child-2" />
40
+ </SplitPage>
41
+ );
42
+ expect(toJSON()).toMatchSnapshot();
9
43
  });
10
44
 
11
45
  it("component is defined", () => {
12
46
  expect(SplitPage).toBeDefined();
13
47
  expect(typeof SplitPage).toBe("function");
14
48
  });
49
+
50
+ it("renders with loading state", () => {
51
+ const {toJSON} = renderWithTheme(
52
+ <SplitPage
53
+ {...defaultProps}
54
+ loading
55
+ renderContent={(selectedId) => <View testID={`content-${selectedId}`} />}
56
+ />
57
+ );
58
+ expect(toJSON()).toMatchSnapshot();
59
+ });
60
+
61
+ it("renders with custom color", () => {
62
+ const {toJSON} = renderWithTheme(
63
+ <SplitPage
64
+ {...defaultProps}
65
+ color="primary"
66
+ renderContent={(selectedId) => <View testID={`content-${selectedId}`} />}
67
+ />
68
+ );
69
+ expect(toJSON()).toMatchSnapshot();
70
+ });
71
+
72
+ it("renders with tabs when more than 2 children", () => {
73
+ const {toJSON} = renderWithTheme(
74
+ <SplitPage {...defaultProps} tabs={["Tab 1", "Tab 2", "Tab 3"]}>
75
+ <View testID="child-1" />
76
+ <View testID="child-2" />
77
+ <View testID="child-3" />
78
+ </SplitPage>
79
+ );
80
+ expect(toJSON()).toMatchSnapshot();
81
+ });
15
82
  });
@@ -1,11 +1,11 @@
1
1
  import type React from "react";
2
2
  import type {FC} from "react";
3
3
  import {Host} from "react-native-portalize";
4
- import {ToastProvider} from "react-native-toast-notifications";
5
4
 
6
5
  import {OpenAPIProvider} from "./OpenAPIContext";
7
6
  import {ThemeProvider} from "./Theme";
8
7
  import {Toast} from "./Toast";
8
+ import {ToastProvider} from "./ToastNotifications";
9
9
 
10
10
  export const TerrenoProvider: FC<{
11
11
  children: React.ReactNode;
package/src/Toast.tsx CHANGED
@@ -1,12 +1,12 @@
1
1
  import type React from "react";
2
2
  import {Platform, Pressable, View} from "react-native";
3
- import {useToast as useRNToast} from "react-native-toast-notifications";
4
3
 
5
4
  import type {IconName, SurfaceColor, TextColor, ToastProps} from "./Common";
6
5
  import {Heading} from "./Heading";
7
6
  import {Icon} from "./Icon";
8
7
  import {Text} from "./Text";
9
8
  import {useTheme} from "./Theme";
9
+ import {useToastNotifications} from "./ToastNotifications";
10
10
  import {isAPIError, printAPIError} from "./Utilities";
11
11
 
12
12
  const TOAST_DURATION_MS = 3 * 1000;
@@ -30,7 +30,7 @@ export function useToast(): {
30
30
  show: (title: string, options?: UseToastOptions) => string;
31
31
  catch: (error: any, message?: string, options?: UseToastVariantOptions) => void;
32
32
  } {
33
- const toast = useRNToast();
33
+ const toast = useToastNotifications();
34
34
  const show = (title: string, options?: UseToastOptions): string => {
35
35
  const toastData = {
36
36
  variant: "info",
@@ -79,7 +79,6 @@ export function useToast(): {
79
79
 
80
80
  // TODO: Support secondary version of Toast.
81
81
  // TODO: Support dismissible version of Toast. Currently only persistent are dismissible.
82
- // This may require a different library from react-native-toast-notifications.
83
82
  export const Toast = ({
84
83
  title,
85
84
  variant = "info",