@terreno/ui 57.20.0 → 57.21.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.
Files changed (112) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/Common.d.ts +55 -27
  3. package/dist/Common.d.ts.map +1 -1
  4. package/dist/Common.js.map +1 -1
  5. package/dist/DateTimeField.js +6 -6
  6. package/dist/DateTimeField.js.map +1 -1
  7. package/dist/HeightField.js +8 -8
  8. package/dist/HeightField.js.map +1 -1
  9. package/dist/OtpField.js +4 -4
  10. package/dist/OtpField.js.map +1 -1
  11. package/dist/PickerSelect.js +9 -9
  12. package/dist/PickerSelect.js.map +1 -1
  13. package/dist/TapToEdit.d.ts +1 -1
  14. package/dist/TapToEdit.d.ts.map +1 -1
  15. package/dist/TapToEdit.js.map +1 -1
  16. package/dist/TextField.js +4 -4
  17. package/dist/TextField.js.map +1 -1
  18. package/dist/Theme.d.ts.map +1 -1
  19. package/dist/Theme.js +16 -0
  20. package/dist/Theme.js.map +1 -1
  21. package/package.json +4 -2
  22. package/src/ActionSheet.test.tsx +13 -13
  23. package/src/AddressField.test.tsx +9 -3
  24. package/src/AnnouncementNavigator.test.tsx +4 -4
  25. package/src/Badge.test.tsx +1 -1
  26. package/src/Banner.test.tsx +0 -1
  27. package/src/Box.test.tsx +82 -74
  28. package/src/Button.test.tsx +11 -6
  29. package/src/Card.test.tsx +2 -2
  30. package/src/Common.ts +60 -29
  31. package/src/ConflictSheet.test.tsx +5 -5
  32. package/src/ConsentFormScreen.test.tsx +3 -1
  33. package/src/ConsentNavigator.test.tsx +1 -2
  34. package/src/CustomSelectField.test.tsx +16 -4
  35. package/src/DataTable.test.tsx +4 -4
  36. package/src/DataTableVirtualizationRegression.test.tsx +1 -0
  37. package/src/DateTimeActionSheet.test.tsx +2 -0
  38. package/src/DateTimeField.test.tsx +3 -12
  39. package/src/DateTimeField.tsx +6 -6
  40. package/src/DismissButton.test.tsx +22 -4
  41. package/src/EmailField.test.tsx +13 -22
  42. package/src/EmojiSelector.test.tsx +2 -2
  43. package/src/ErrorBoundary.test.tsx +5 -3
  44. package/src/Field.test.tsx +20 -44
  45. package/src/GPTChat.test.tsx +24 -16
  46. package/src/Heading.test.tsx +1 -1
  47. package/src/HeightField.tsx +8 -8
  48. package/src/Icon.test.tsx +2 -2
  49. package/src/Image.test.tsx +1 -1
  50. package/src/Link.test.tsx +11 -4
  51. package/src/MarkdownView.test.tsx +1 -1
  52. package/src/MobileAddressAutoComplete.test.tsx +2 -1
  53. package/src/Modal.test.tsx +7 -2
  54. package/src/ModalSheet.test.tsx +5 -4
  55. package/src/MultiselectField.test.tsx +17 -3
  56. package/src/NumberField.test.tsx +14 -14
  57. package/src/NumberPickerActionSheet.test.tsx +1 -1
  58. package/src/OpenAPIContext.test.tsx +4 -4
  59. package/src/OpenAPIRenderRegression.test.tsx +1 -1
  60. package/src/OtpField.tsx +4 -4
  61. package/src/P0RenderRegression.test.tsx +7 -1
  62. package/src/P1RenderRegression.test.tsx +1 -0
  63. package/src/P2ButtonRenderRegression.test.tsx +1 -0
  64. package/src/Page.test.tsx +1 -1
  65. package/src/PhoneNumberField.test.tsx +14 -38
  66. package/src/PickerSelect.tsx +9 -9
  67. package/src/Popover.test.tsx +2 -2
  68. package/src/RadioField.test.tsx +7 -2
  69. package/src/SegmentedControl.test.tsx +21 -12
  70. package/src/SidebarNavigation.test.tsx +18 -6
  71. package/src/Signature.test.tsx +20 -23
  72. package/src/Slider.test.tsx +1 -1
  73. package/src/SplitPage.test.tsx +15 -5
  74. package/src/TapToEdit.test.tsx +38 -15
  75. package/src/TapToEdit.tsx +1 -1
  76. package/src/TerrenoFontProvider.test.tsx +1 -1
  77. package/src/Text.test.tsx +4 -4
  78. package/src/TextField.test.tsx +82 -9
  79. package/src/TextField.tsx +4 -4
  80. package/src/Theme.test.tsx +49 -0
  81. package/src/Theme.tsx +16 -0
  82. package/src/Toast.test.tsx +5 -5
  83. package/src/ToastNotifications.test.tsx +73 -70
  84. package/src/ToastNotifications.webModal.test.tsx +2 -2
  85. package/src/Tooltip.test.tsx +3 -3
  86. package/src/UnifiedAddressAutoComplete.test.tsx +1 -1
  87. package/src/UserInactivity.test.tsx +4 -2
  88. package/src/WebAddressAutocomplete.test.tsx +12 -12
  89. package/src/WebDropdownMenu.test.tsx +16 -15
  90. package/src/__snapshots__/Card.test.tsx.snap +1 -1
  91. package/src/__snapshots__/DismissButton.test.tsx.snap +3 -3
  92. package/src/__snapshots__/Field.test.tsx.snap +4 -2
  93. package/src/__snapshots__/Heading.test.tsx.snap +1 -1
  94. package/src/__snapshots__/Image.test.tsx.snap +1 -1
  95. package/src/__snapshots__/Page.test.tsx.snap +2 -2
  96. package/src/__snapshots__/Text.test.tsx.snap +1 -1
  97. package/src/asks/AskCard.test.tsx +16 -13
  98. package/src/asks/AskFiles.test.tsx +5 -1
  99. package/src/asks/askFileRefs.test.ts +1 -1
  100. package/src/asks/askSummary.test.ts +2 -2
  101. package/src/benchmarks/importTiming.ts +1 -1
  102. package/src/blocks/BlocksView.test.tsx +20 -11
  103. package/src/bunSetup.ts +1 -1
  104. package/src/dataTableFilters.test.tsx +1 -1
  105. package/src/isolated/ListDetailLayout.isolated.tsx +2 -4
  106. package/src/login/LoginScreen.test.tsx +6 -6
  107. package/src/security/PasswordCard.test.tsx +3 -3
  108. package/src/signUp/SignUpScreen.test.tsx +4 -4
  109. package/src/table/tableContext.test.tsx +5 -5
  110. package/src/test-utils.tsx +56 -1
  111. package/src/testing/reactDomServer.d.ts +7 -0
  112. package/src/useConsentForms.test.ts +1 -1
@@ -87,7 +87,7 @@ describe("NumberPickerActionSheet", () => {
87
87
  );
88
88
  // Replace the ref target with a mock after mount so the Button's onClick
89
89
  // invokes our spy instead of the real ActionSheet instance.
90
- (actionSheetRef as {current: {setModalVisible: typeof setModalVisible}}).current = {
90
+ (actionSheetRef as unknown as {current: {setModalVisible: typeof setModalVisible}}).current = {
91
91
  setModalVisible,
92
92
  };
93
93
  const closeButtons = UNSAFE_getAllByProps({text: "Close"});
@@ -100,7 +100,7 @@ describe("OpenAPIContext", () => {
100
100
  });
101
101
 
102
102
  it("fetches spec and resolves model fields", async () => {
103
- let capturedContext: OpenAPIContextType | null = null;
103
+ let capturedContext = null as OpenAPIContextType | null;
104
104
  render(
105
105
  <OpenAPIProvider specUrl="https://api.example.com/openapi.json">
106
106
  <ContextReader
@@ -125,7 +125,7 @@ describe("OpenAPIContext", () => {
125
125
  });
126
126
 
127
127
  it("resolves nested model fields using dot notation", async () => {
128
- let capturedContext: OpenAPIContextType | null = null;
128
+ let capturedContext = null as OpenAPIContextType | null;
129
129
  render(
130
130
  <OpenAPIProvider specUrl="https://api.example.com/openapi.json">
131
131
  <ContextReader
@@ -147,7 +147,7 @@ describe("OpenAPIContext", () => {
147
147
  });
148
148
 
149
149
  it("warns when model path is missing", async () => {
150
- let capturedContext: OpenAPIContextType | null = null;
150
+ let capturedContext = null as OpenAPIContextType | null;
151
151
  render(
152
152
  <OpenAPIProvider specUrl="https://api.example.com/openapi.json">
153
153
  <ContextReader
@@ -167,7 +167,7 @@ describe("OpenAPIContext", () => {
167
167
  });
168
168
 
169
169
  it("warns when model field is missing", async () => {
170
- let capturedContext: OpenAPIContextType | null = null;
170
+ let capturedContext = null as OpenAPIContextType | null;
171
171
  render(
172
172
  <OpenAPIProvider specUrl="https://api.example.com/openapi.json">
173
173
  <ContextReader
@@ -164,7 +164,7 @@ describe("OpenAPI context rerender regression coverage", () => {
164
164
  });
165
165
 
166
166
  it("keeps stable OpenAPI action references across equivalent provider renders", async () => {
167
- let capturedContext: ReturnType<typeof useOpenAPISpec> | null = null;
167
+ let capturedContext = null as ReturnType<typeof useOpenAPISpec> | null;
168
168
 
169
169
  const result = render(
170
170
  <OpenAPIProvider specUrl="https://api.example.com/openapi-v0.json">
package/src/OtpField.tsx CHANGED
@@ -230,14 +230,14 @@ export const OtpField: FC<OtpFieldProps> = ({
230
230
 
231
231
  const renderCell = (index: number): ReactElement => {
232
232
  const isFocused = focusedIndex === index;
233
- let borderColor = theme.border.dark;
233
+ let borderColor = theme.field.border;
234
234
  let borderWidth = 1;
235
235
  if (errorText || invalid) {
236
- borderColor = theme.border.error;
236
+ borderColor = theme.field.borderError;
237
237
  borderWidth = 2;
238
238
  }
239
239
  if (isFocused) {
240
- borderColor = theme.border.focus;
240
+ borderColor = theme.field.borderFocus;
241
241
  borderWidth = 3;
242
242
  }
243
243
  return (
@@ -266,7 +266,7 @@ export const OtpField: FC<OtpFieldProps> = ({
266
266
  selectTextOnFocus
267
267
  style={
268
268
  {
269
- backgroundColor: disabled ? theme.surface.neutralLight : theme.surface.base,
269
+ backgroundColor: disabled ? theme.field.backgroundDisabled : theme.field.background,
270
270
  borderColor,
271
271
  borderRadius: 4,
272
272
  borderWidth,
@@ -1,3 +1,4 @@
1
+ import {describe, it} from "bun:test";
1
2
  import {act, render, waitFor} from "@testing-library/react-native";
2
3
  import {assert} from "chai";
3
4
  import type React from "react";
@@ -88,7 +89,12 @@ describe("P0 component rerender regression coverage", () => {
88
89
  assert.exists(result.getByTestId("box"));
89
90
  result.rerender(
90
91
  <ThemeProvider>
91
- <Box onClick={onClick} testID="box" />
92
+ <Box
93
+ accessibilityHint="Runs the box action"
94
+ accessibilityLabel="Box action"
95
+ onClick={onClick}
96
+ testID="box"
97
+ />
92
98
  </ThemeProvider>
93
99
  );
94
100
 
@@ -1,3 +1,4 @@
1
+ import {describe, it} from "bun:test";
1
2
  import {act, render} from "@testing-library/react-native";
2
3
  import {assert} from "chai";
3
4
  import type React from "react";
@@ -1,3 +1,4 @@
1
+ import {describe, it} from "bun:test";
1
2
  import {act, fireEvent, render} from "@testing-library/react-native";
2
3
  import {assert} from "chai";
3
4
  import type React from "react";
package/src/Page.test.tsx CHANGED
@@ -194,7 +194,7 @@ describe("Page", () => {
194
194
 
195
195
  it("renders with custom color", () => {
196
196
  const {toJSON} = renderWithTheme(
197
- <Page color="secondary" navigation={mockNavigation}>
197
+ <Page color="secondaryDark" navigation={mockNavigation}>
198
198
  <Text>Content</Text>
199
199
  </Page>
200
200
  );
@@ -6,65 +6,46 @@ import {renderWithTheme} from "./test-utils";
6
6
 
7
7
  describe("PhoneNumberField", () => {
8
8
  it("renders correctly with default props", () => {
9
- const {toJSON} = renderWithTheme(
10
- <PhoneNumberField label="Phone" onChange={() => {}} value="" />
11
- );
9
+ const {toJSON} = renderWithTheme(<PhoneNumberField onChange={() => {}} value="" />);
12
10
  expect(toJSON()).toMatchSnapshot();
13
11
  });
14
12
 
15
13
  it("renders with placeholder", () => {
16
14
  const {getByPlaceholderText} = renderWithTheme(
17
- <PhoneNumberField
18
- label="Phone"
19
- onChange={() => {}}
20
- placeholder="Enter phone number"
21
- value=""
22
- />
15
+ <PhoneNumberField onChange={() => {}} placeholder="Enter phone number" value="" />
23
16
  );
24
17
  expect(getByPlaceholderText("Enter phone number")).toBeTruthy();
25
18
  });
26
19
 
27
20
  it("renders with initial value", () => {
28
21
  const {getByDisplayValue} = renderWithTheme(
29
- <PhoneNumberField label="Phone" onChange={() => {}} value="(555) 123-4567" />
22
+ <PhoneNumberField onChange={() => {}} value="(555) 123-4567" />
30
23
  );
31
24
  expect(getByDisplayValue("(555) 123-4567")).toBeTruthy();
32
25
  });
33
26
 
34
27
  it("renders with custom errorText", () => {
35
28
  const {getByText} = renderWithTheme(
36
- <PhoneNumberField
37
- errorText="Phone number is required"
38
- label="Phone"
39
- onChange={() => {}}
40
- value=""
41
- />
29
+ <PhoneNumberField errorText="Phone number is required" onChange={() => {}} value="" />
42
30
  );
43
31
  expect(getByText("Phone number is required")).toBeTruthy();
44
32
  });
45
33
 
46
34
  it("renders with icon", () => {
47
35
  const {toJSON} = renderWithTheme(
48
- <PhoneNumberField iconName="phone" label="Phone" onChange={() => {}} value="" />
36
+ <PhoneNumberField iconName="phone" onChange={() => {}} value="" />
49
37
  );
50
38
  expect(toJSON()).toMatchSnapshot();
51
39
  });
52
40
 
53
41
  it("uses US as default country code", () => {
54
- const {toJSON} = renderWithTheme(
55
- <PhoneNumberField label="Phone" onChange={() => {}} value="5551234567" />
56
- );
42
+ const {toJSON} = renderWithTheme(<PhoneNumberField onChange={() => {}} value="5551234567" />);
57
43
  expect(toJSON()).toMatchSnapshot();
58
44
  });
59
45
 
60
46
  it("accepts custom country code", () => {
61
47
  const {toJSON} = renderWithTheme(
62
- <PhoneNumberField
63
- defaultCountryCode="GB"
64
- label="Phone"
65
- onChange={() => {}}
66
- value="7911123456"
67
- />
48
+ <PhoneNumberField defaultCountryCode="GB" onChange={() => {}} value="7911123456" />
68
49
  );
69
50
  expect(toJSON()).toMatchSnapshot();
70
51
  });
@@ -73,12 +54,7 @@ describe("PhoneNumberField", () => {
73
54
  const handleBlur = mock((_value: string) => {});
74
55
  const handleChange = mock((_value: string) => {});
75
56
  const {getByDisplayValue} = renderWithTheme(
76
- <PhoneNumberField
77
- label="Phone"
78
- onBlur={handleBlur}
79
- onChange={handleChange}
80
- value="(555) 123-4567"
81
- />
57
+ <PhoneNumberField onBlur={handleBlur} onChange={handleChange} value="(555) 123-4567" />
82
58
  );
83
59
  const input = getByDisplayValue("(555) 123-4567");
84
60
  await act(async () => {
@@ -91,7 +67,7 @@ describe("PhoneNumberField", () => {
91
67
  const handleBlur = mock((_value: string) => {});
92
68
  const handleChange = mock((_value: string) => {});
93
69
  const {getByDisplayValue} = renderWithTheme(
94
- <PhoneNumberField label="Phone" onBlur={handleBlur} onChange={handleChange} value="" />
70
+ <PhoneNumberField onBlur={handleBlur} onChange={handleChange} value="" />
95
71
  );
96
72
  const input = getByDisplayValue("");
97
73
  await act(async () => {
@@ -105,7 +81,7 @@ describe("PhoneNumberField", () => {
105
81
  const handleBlur = mock((_value: string) => {});
106
82
  const handleChange = mock((_value: string) => {});
107
83
  const {getByDisplayValue} = renderWithTheme(
108
- <PhoneNumberField label="Phone" onBlur={handleBlur} onChange={handleChange} value="" />
84
+ <PhoneNumberField onBlur={handleBlur} onChange={handleChange} value="" />
109
85
  );
110
86
  const input = getByDisplayValue("");
111
87
  await act(async () => {
@@ -117,7 +93,7 @@ describe("PhoneNumberField", () => {
117
93
  it("shows 'Invalid phone number format' on blur when number cannot be parsed", async () => {
118
94
  const handleChange = mock((_value: string) => {});
119
95
  const {getByDisplayValue, getByText} = renderWithTheme(
120
- <PhoneNumberField label="Phone" onChange={handleChange} value="abc" />
96
+ <PhoneNumberField onChange={handleChange} value="abc" />
121
97
  );
122
98
  const input = getByDisplayValue("abc");
123
99
  await act(async () => {
@@ -130,7 +106,7 @@ describe("PhoneNumberField", () => {
130
106
  const handleChange = mock((_value: string) => {});
131
107
  // A number that parses and isPossible() but not isValid() for US
132
108
  const {getByDisplayValue, getByText} = renderWithTheme(
133
- <PhoneNumberField label="Phone" onChange={handleChange} value="(555) 555-5555" />
109
+ <PhoneNumberField onChange={handleChange} value="(555) 555-5555" />
134
110
  );
135
111
  const input = getByDisplayValue("(555) 555-5555");
136
112
  await act(async () => {
@@ -142,7 +118,7 @@ describe("PhoneNumberField", () => {
142
118
  it("uses inputValue as-is when it matches formattedValue or has length 4", async () => {
143
119
  const handleChange = mock((_value: string) => {});
144
120
  const {getByDisplayValue} = renderWithTheme(
145
- <PhoneNumberField label="Phone" onChange={handleChange} value="" />
121
+ <PhoneNumberField onChange={handleChange} value="" />
146
122
  );
147
123
  const input = getByDisplayValue("");
148
124
  // Input of length 4 triggers the else branch (setLocalValue(inputValue))
@@ -157,7 +133,7 @@ describe("PhoneNumberField", () => {
157
133
  // Start with an invalid value so that blur triggers the error path.
158
134
  // TextField's onBlur uses its own value prop (localValue), not nativeEvent.text.
159
135
  const {getByDisplayValue, getByText, queryByText} = renderWithTheme(
160
- <PhoneNumberField label="Phone" onChange={handleChange} value="abc" />
136
+ <PhoneNumberField onChange={handleChange} value="abc" />
161
137
  );
162
138
  const input = getByDisplayValue("abc");
163
139
  // Blur triggers validatePhoneNumber("abc") → "Invalid phone number format"
@@ -469,11 +469,11 @@ export const RNPickerSelect = ({
469
469
  style={[
470
470
  defaultStyles.viewContainer,
471
471
  {
472
- backgroundColor: theme.surface.base,
473
- borderColor: theme.border.dark,
472
+ backgroundColor: theme.field.background,
473
+ borderColor: theme.field.border,
474
474
  },
475
475
  disabled && {
476
- backgroundColor: theme.surface.neutralLight,
476
+ backgroundColor: theme.field.backgroundDisabled,
477
477
  },
478
478
  ]}
479
479
  >
@@ -589,12 +589,12 @@ export const RNPickerSelect = ({
589
589
  style={[
590
590
  defaultStyles.viewContainer,
591
591
  {
592
- backgroundColor: theme.surface.base,
593
- borderColor: theme.border.dark,
592
+ backgroundColor: theme.field.background,
593
+ borderColor: theme.field.border,
594
594
  height: 40,
595
595
  },
596
596
  disabled && {
597
- backgroundColor: theme.surface.neutralLight,
597
+ backgroundColor: theme.field.backgroundDisabled,
598
598
  },
599
599
  ]}
600
600
  >
@@ -742,11 +742,11 @@ export const RNPickerSelect = ({
742
742
  style={[
743
743
  defaultStyles.viewContainer,
744
744
  {
745
- backgroundColor: theme.surface.base,
746
- borderColor: theme.border.dark,
745
+ backgroundColor: theme.field.background,
746
+ borderColor: theme.field.border,
747
747
  },
748
748
  disabled && {
749
- backgroundColor: theme.surface.neutralLight,
749
+ backgroundColor: theme.field.backgroundDisabled,
750
750
  },
751
751
  ]}
752
752
  >
@@ -3,7 +3,7 @@ import {fireEvent, waitFor} from "@testing-library/react-native";
3
3
 
4
4
  import {Popover} from "./Popover";
5
5
  import {Text} from "./Text";
6
- import {renderWithTheme} from "./test-utils";
6
+ import {findByHostType, renderWithTheme} from "./test-utils";
7
7
 
8
8
  describe("Popover", () => {
9
9
  it("renders the title, date and body when loaded", () => {
@@ -110,7 +110,7 @@ describe("Popover", () => {
110
110
  expect(scrollView.props.style).toEqual(
111
111
  expect.objectContaining({flexBasis: 0, flexGrow: 1, flexShrink: 1, minHeight: 0})
112
112
  );
113
- const content = scrollView.findByType("View");
113
+ const content = findByHostType(scrollView, "View");
114
114
  expect(content.props.style?.height).toBeUndefined();
115
115
  });
116
116
 
@@ -1,6 +1,6 @@
1
1
  import {describe, expect, it, mock} from "bun:test";
2
2
  import {fireEvent} from "@testing-library/react-native";
3
-
3
+ import type {FieldOption} from "./Common";
4
4
  import {RadioField} from "./RadioField";
5
5
  import {renderWithTheme} from "./test-utils";
6
6
 
@@ -78,7 +78,12 @@ describe("RadioField", () => {
78
78
  });
79
79
 
80
80
  it("renders options using value when label is not provided", () => {
81
- const optionsWithoutLabels = [{value: "first"}, {value: "second"}, {value: "third"}];
81
+ // FieldOption requires a label; untyped callers can still omit it.
82
+ const optionsWithoutLabels = [
83
+ {value: "first"},
84
+ {value: "second"},
85
+ {value: "third"},
86
+ ] as unknown as FieldOption[];
82
87
  const {getByText} = renderWithTheme(
83
88
  <RadioField onChange={() => {}} options={optionsWithoutLabels} title="Title" value="" />
84
89
  );
@@ -8,13 +8,15 @@ describe("SegmentedControl", () => {
8
8
  const defaultItems = ["Tab 1", "Tab 2", "Tab 3"];
9
9
 
10
10
  it("renders correctly with default props", () => {
11
- const {toJSON} = renderWithTheme(<SegmentedControl items={defaultItems} selectedIndex={0} />);
11
+ const {toJSON} = renderWithTheme(
12
+ <SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={0} />
13
+ );
12
14
  expect(toJSON()).toMatchSnapshot();
13
15
  });
14
16
 
15
17
  it("renders all items", () => {
16
18
  const {getByText} = renderWithTheme(
17
- <SegmentedControl items={defaultItems} selectedIndex={0} />
19
+ <SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={0} />
18
20
  );
19
21
  expect(getByText("Tab 1")).toBeTruthy();
20
22
  expect(getByText("Tab 2")).toBeTruthy();
@@ -22,7 +24,9 @@ describe("SegmentedControl", () => {
22
24
  });
23
25
 
24
26
  it("highlights selected item", () => {
25
- const {toJSON} = renderWithTheme(<SegmentedControl items={defaultItems} selectedIndex={1} />);
27
+ const {toJSON} = renderWithTheme(
28
+ <SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={1} />
29
+ );
26
30
  expect(toJSON()).toMatchSnapshot();
27
31
  });
28
32
 
@@ -38,21 +42,21 @@ describe("SegmentedControl", () => {
38
42
 
39
43
  it("renders with medium size (default)", () => {
40
44
  const {toJSON} = renderWithTheme(
41
- <SegmentedControl items={defaultItems} selectedIndex={0} size="md" />
45
+ <SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={0} size="md" />
42
46
  );
43
47
  expect(toJSON()).toMatchSnapshot();
44
48
  });
45
49
 
46
50
  it("renders a compact control that hugs its labels", () => {
47
51
  const {toJSON} = renderWithTheme(
48
- <SegmentedControl items={defaultItems} selectedIndex={0} size="sm" />
52
+ <SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={0} size="sm" />
49
53
  );
50
54
  expect(toJSON()).toMatchSnapshot();
51
55
  });
52
56
 
53
57
  it("renders with large size", () => {
54
58
  const {toJSON} = renderWithTheme(
55
- <SegmentedControl items={defaultItems} selectedIndex={0} size="lg" />
59
+ <SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={0} size="lg" />
56
60
  );
57
61
  expect(toJSON()).toMatchSnapshot();
58
62
  });
@@ -64,7 +68,12 @@ describe("SegmentedControl", () => {
64
68
  {count: 1, status: "error" as const},
65
69
  ];
66
70
  const {toJSON} = renderWithTheme(
67
- <SegmentedControl badges={badges} items={defaultItems} selectedIndex={0} />
71
+ <SegmentedControl
72
+ badges={badges}
73
+ items={defaultItems}
74
+ onChange={() => {}}
75
+ selectedIndex={0}
76
+ />
68
77
  );
69
78
  expect(toJSON()).toMatchSnapshot();
70
79
  });
@@ -72,7 +81,7 @@ describe("SegmentedControl", () => {
72
81
  it("renders with maxItems and scroll buttons", () => {
73
82
  const manyItems = ["Tab 1", "Tab 2", "Tab 3", "Tab 4", "Tab 5", "Tab 6"];
74
83
  const {toJSON} = renderWithTheme(
75
- <SegmentedControl items={manyItems} maxItems={3} selectedIndex={0} />
84
+ <SegmentedControl items={manyItems} maxItems={3} onChange={() => {}} selectedIndex={0} />
76
85
  );
77
86
  expect(toJSON()).toMatchSnapshot();
78
87
  });
@@ -80,7 +89,7 @@ describe("SegmentedControl", () => {
80
89
  it("handles scroll navigation", () => {
81
90
  const manyItems = ["Tab 1", "Tab 2", "Tab 3", "Tab 4", "Tab 5", "Tab 6"];
82
91
  const {getByText, toJSON} = renderWithTheme(
83
- <SegmentedControl items={manyItems} maxItems={3} selectedIndex={0} />
92
+ <SegmentedControl items={manyItems} maxItems={3} onChange={() => {}} selectedIndex={0} />
84
93
  );
85
94
  // Initially shows first 3 items
86
95
  expect(getByText("Tab 1")).toBeTruthy();
@@ -92,7 +101,7 @@ describe("SegmentedControl", () => {
92
101
  it("invokes handleNext when next scroll button is pressed", () => {
93
102
  const manyItems = ["Tab 1", "Tab 2", "Tab 3", "Tab 4", "Tab 5", "Tab 6"];
94
103
  const {UNSAFE_getAllByProps, queryByText} = renderWithTheme(
95
- <SegmentedControl items={manyItems} maxItems={3} selectedIndex={0} />
104
+ <SegmentedControl items={manyItems} maxItems={3} onChange={() => {}} selectedIndex={0} />
96
105
  );
97
106
  // Find the right chevron (next button) by its icon prop
98
107
  const nextIcons = UNSAFE_getAllByProps({iconName: "chevron-right"});
@@ -109,7 +118,7 @@ describe("SegmentedControl", () => {
109
118
 
110
119
  it("uses the default no-op onChange when none is provided", () => {
111
120
  const {getByText} = renderWithTheme(
112
- <SegmentedControl items={defaultItems} selectedIndex={0} />
121
+ <SegmentedControl items={defaultItems} onChange={() => {}} selectedIndex={0} />
113
122
  );
114
123
 
115
124
  expect(() => fireEvent.press(getByText("Tab 2"))).not.toThrow();
@@ -118,7 +127,7 @@ describe("SegmentedControl", () => {
118
127
  it("invokes handlePrevious when previous scroll button is pressed", () => {
119
128
  const manyItems = ["Tab 1", "Tab 2", "Tab 3", "Tab 4", "Tab 5", "Tab 6"];
120
129
  const {UNSAFE_getAllByProps, queryByText} = renderWithTheme(
121
- <SegmentedControl items={manyItems} maxItems={3} selectedIndex={0} />
130
+ <SegmentedControl items={manyItems} maxItems={3} onChange={() => {}} selectedIndex={0} />
122
131
  );
123
132
  const nextIcons = UNSAFE_getAllByProps({iconName: "chevron-right"});
124
133
  const nextPressable = nextIcons[0].parent;
@@ -103,7 +103,9 @@ describe("SidebarNavigationPanel", () => {
103
103
  bottomItems={bottomItems}
104
104
  onNavigate={onNavigate}
105
105
  topItems={topItems}
106
- />
106
+ >
107
+ {null}
108
+ </SidebarNavigationPanel>
107
109
  );
108
110
 
109
111
  for (const item of [...topItems, ...bottomItems]) {
@@ -134,7 +136,9 @@ describe("SidebarNavigationPanel", () => {
134
136
  bottomItems={bottomItems}
135
137
  onNavigate={onNavigate}
136
138
  topItems={topItems}
137
- />
139
+ >
140
+ {null}
141
+ </SidebarNavigationPanel>
138
142
  );
139
143
 
140
144
  fireEvent.press(getByLabelText("Settings"));
@@ -148,7 +152,9 @@ describe("SidebarNavigationPanel", () => {
148
152
  bottomItems={bottomItems}
149
153
  onNavigate={mock((_route: string) => {})}
150
154
  topItems={topItems}
151
- />
155
+ >
156
+ {null}
157
+ </SidebarNavigationPanel>
152
158
  );
153
159
 
154
160
  expect(queryByText("Home")).toBeNull();
@@ -175,7 +181,9 @@ describe("SidebarNavigationPanel", () => {
175
181
  bottomItems={bottomItems}
176
182
  onNavigate={mock((_route: string) => {})}
177
183
  topItems={topItems}
178
- />
184
+ >
185
+ {null}
186
+ </SidebarNavigationPanel>
179
187
  );
180
188
 
181
189
  const rail = UNSAFE_getAllByType(View).find((node) => node.props.onMouseEnter !== undefined);
@@ -203,7 +211,9 @@ describe("SidebarNavigationPanel", () => {
203
211
  bottomItems={bottomItems}
204
212
  onNavigate={mock((_route: string) => {})}
205
213
  topItems={topItems}
206
- />
214
+ >
215
+ {null}
216
+ </SidebarNavigationPanel>
207
217
  );
208
218
 
209
219
  const item = getByLabelText("Alerts");
@@ -229,7 +239,9 @@ describe("SidebarNavigationPanel", () => {
229
239
  onNavigate={mock((_route: string) => {})}
230
240
  panelStyle={{borderRightWidth: 4}}
231
241
  topItems={topItems}
232
- />
242
+ >
243
+ {null}
244
+ </SidebarNavigationPanel>
233
245
  );
234
246
 
235
247
  const rail = UNSAFE_getAllByType(View).find((node) => node.props.onMouseEnter !== undefined);