@terreno/ui 57.11.0 → 57.13.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 (166) hide show
  1. package/dist/AiSuggestionBox.js +9 -9
  2. package/dist/AiSuggestionBox.js.map +1 -1
  3. package/dist/Banner.js +1 -1
  4. package/dist/Banner.js.map +1 -1
  5. package/dist/Box.d.ts.map +1 -1
  6. package/dist/Box.js +36 -3
  7. package/dist/Box.js.map +1 -1
  8. package/dist/Button.d.ts.map +1 -1
  9. package/dist/Button.js +7 -0
  10. package/dist/Button.js.map +1 -1
  11. package/dist/Common.d.ts +34 -4
  12. package/dist/Common.d.ts.map +1 -1
  13. package/dist/Common.js.map +1 -1
  14. package/dist/DataTable.d.ts.map +1 -1
  15. package/dist/DataTable.js +50 -3
  16. package/dist/DataTable.js.map +1 -1
  17. package/dist/Image.d.ts.map +1 -1
  18. package/dist/Image.js +1 -1
  19. package/dist/Image.js.map +1 -1
  20. package/dist/MarkdownView.d.ts.map +1 -1
  21. package/dist/MarkdownView.js +67 -5
  22. package/dist/MarkdownView.js.map +1 -1
  23. package/dist/Modal.js +1 -1
  24. package/dist/SegmentedControl.d.ts.map +1 -1
  25. package/dist/SegmentedControl.js +15 -11
  26. package/dist/SegmentedControl.js.map +1 -1
  27. package/dist/SelectField.d.ts.map +1 -1
  28. package/dist/SelectField.js +4 -1
  29. package/dist/SelectField.js.map +1 -1
  30. package/dist/SplitPage.d.ts.map +1 -1
  31. package/dist/SplitPage.js +145 -55
  32. package/dist/SplitPage.js.map +1 -1
  33. package/dist/SplitPage.native.js +1 -1
  34. package/dist/SplitPage.native.js.map +1 -1
  35. package/dist/TerrenoProvider.d.ts +7 -3
  36. package/dist/TerrenoProvider.d.ts.map +1 -1
  37. package/dist/TerrenoProvider.js +2 -2
  38. package/dist/TerrenoProvider.js.map +1 -1
  39. package/dist/Theme.d.ts +19 -85
  40. package/dist/Theme.d.ts.map +1 -1
  41. package/dist/Theme.js +149 -33
  42. package/dist/Theme.js.map +1 -1
  43. package/dist/Toast.d.ts.map +1 -1
  44. package/dist/Toast.js +21 -12
  45. package/dist/Toast.js.map +1 -1
  46. package/dist/ToastNotifications.d.ts.map +1 -1
  47. package/dist/ToastNotifications.js +5 -2
  48. package/dist/ToastNotifications.js.map +1 -1
  49. package/dist/Tooltip.d.ts +1 -0
  50. package/dist/Tooltip.d.ts.map +1 -1
  51. package/dist/Tooltip.js +84 -37
  52. package/dist/Tooltip.js.map +1 -1
  53. package/dist/blocks/BlocksView.d.ts.map +1 -1
  54. package/dist/blocks/BlocksView.js +5 -1
  55. package/dist/blocks/BlocksView.js.map +1 -1
  56. package/dist/blocks/blockRenderers.d.ts +10 -1
  57. package/dist/blocks/blockRenderers.d.ts.map +1 -1
  58. package/dist/blocks/blockRenderers.js +330 -9
  59. package/dist/blocks/blockRenderers.js.map +1 -1
  60. package/dist/blocks/useChecklistState.d.ts +18 -0
  61. package/dist/blocks/useChecklistState.d.ts.map +1 -0
  62. package/dist/blocks/useChecklistState.js +29 -0
  63. package/dist/blocks/useChecklistState.js.map +1 -0
  64. package/dist/blocks/useResolvedImages.d.ts.map +1 -1
  65. package/dist/blocks/useResolvedImages.js +16 -0
  66. package/dist/blocks/useResolvedImages.js.map +1 -1
  67. package/dist/colorContrast.d.ts +9 -0
  68. package/dist/colorContrast.d.ts.map +1 -0
  69. package/dist/colorContrast.js +47 -0
  70. package/dist/colorContrast.js.map +1 -0
  71. package/dist/icons/OfflineIcon.js +1 -1
  72. package/dist/table/TableDate.d.ts.map +1 -1
  73. package/dist/table/TableDate.js +3 -1
  74. package/dist/table/TableDate.js.map +1 -1
  75. package/package.json +2 -2
  76. package/src/AiSuggestionBox.tsx +10 -10
  77. package/src/Banner.tsx +1 -1
  78. package/src/Box.test.tsx +80 -0
  79. package/src/Box.tsx +52 -0
  80. package/src/Button.test.tsx +39 -1
  81. package/src/Button.tsx +9 -0
  82. package/src/Common.ts +35 -4
  83. package/src/DataTable.test.tsx +133 -1
  84. package/src/DataTable.tsx +78 -3
  85. package/src/Image.tsx +1 -0
  86. package/src/MarkdownView.test.tsx +165 -2
  87. package/src/MarkdownView.tsx +100 -5
  88. package/src/Modal.tsx +1 -1
  89. package/src/SegmentedControl.test.tsx +7 -0
  90. package/src/SegmentedControl.tsx +22 -11
  91. package/src/SelectField.tsx +4 -1
  92. package/src/SplitPage.native.tsx +1 -1
  93. package/src/SplitPage.test.tsx +473 -5
  94. package/src/SplitPage.tsx +266 -132
  95. package/src/TerrenoProvider.tsx +15 -5
  96. package/src/Theme.test.tsx +212 -3
  97. package/src/Theme.tsx +184 -39
  98. package/src/Toast.test.tsx +7 -0
  99. package/src/Toast.tsx +22 -12
  100. package/src/ToastNotifications.test.tsx +36 -0
  101. package/src/ToastNotifications.tsx +5 -2
  102. package/src/Tooltip.test.tsx +232 -1
  103. package/src/Tooltip.tsx +128 -67
  104. package/src/__snapshots__/AddressField.test.tsx.snap +7 -7
  105. package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +23 -23
  106. package/src/__snapshots__/Banner.test.tsx.snap +3 -0
  107. package/src/__snapshots__/BooleanField.test.tsx.snap +3 -3
  108. package/src/__snapshots__/Button.test.tsx.snap +16 -16
  109. package/src/__snapshots__/Card.test.tsx.snap +0 -1
  110. package/src/__snapshots__/CustomSelectField.test.tsx.snap +23 -23
  111. package/src/__snapshots__/DataTable.test.tsx.snap +30 -30
  112. package/src/__snapshots__/DecimalRangeActionSheet.test.tsx.snap +2 -2
  113. package/src/__snapshots__/DropdownPanel.test.tsx.snap +2 -2
  114. package/src/__snapshots__/EmailField.test.tsx.snap +2 -2
  115. package/src/__snapshots__/ErrorPage.test.tsx.snap +1 -1
  116. package/src/__snapshots__/Field.test.tsx.snap +37 -37
  117. package/src/__snapshots__/FilterSelectMenu.test.tsx.snap +2 -1
  118. package/src/__snapshots__/HeightActionSheet.test.tsx.snap +2 -2
  119. package/src/__snapshots__/HeightField.test.tsx.snap +8 -8
  120. package/src/__snapshots__/HeightFieldDesktop.test.tsx.snap +6 -6
  121. package/src/__snapshots__/InfoModalIcon.test.tsx.snap +2 -2
  122. package/src/__snapshots__/MarkdownView.test.tsx.snap +2 -2
  123. package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +1 -1
  124. package/src/__snapshots__/Modal.test.tsx.snap +10 -10
  125. package/src/__snapshots__/NumberField.test.tsx.snap +1 -1
  126. package/src/__snapshots__/NumberPickerActionSheet.test.tsx.snap +2 -2
  127. package/src/__snapshots__/Page.test.tsx.snap +1 -1
  128. package/src/__snapshots__/PhoneNumberField.test.tsx.snap +4 -4
  129. package/src/__snapshots__/PickerSelect.test.tsx.snap +8 -8
  130. package/src/__snapshots__/SectionDivider.test.tsx.snap +2 -2
  131. package/src/__snapshots__/SegmentedControl.test.tsx.snap +183 -0
  132. package/src/__snapshots__/SelectBadge.test.tsx.snap +9 -9
  133. package/src/__snapshots__/SelectField.test.tsx.snap +19 -19
  134. package/src/__snapshots__/Signature.test.tsx.snap +1 -1
  135. package/src/__snapshots__/SignatureCaptureField.test.tsx.snap +2 -2
  136. package/src/__snapshots__/SignatureField.test.tsx.snap +2 -2
  137. package/src/__snapshots__/SplitPage.test.tsx.snap +165 -67
  138. package/src/__snapshots__/TapToEdit.test.tsx.snap +1 -1
  139. package/src/__snapshots__/TerrenoProvider.test.tsx.snap +20 -4
  140. package/src/__snapshots__/TextArea.test.tsx.snap +4 -4
  141. package/src/__snapshots__/TextField.test.tsx.snap +3 -3
  142. package/src/__snapshots__/TimezonePicker.test.tsx.snap +18 -18
  143. package/src/__snapshots__/Toast.test.tsx.snap +224 -154
  144. package/src/__snapshots__/TypedSignatureField.test.tsx.snap +3 -3
  145. package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +6 -6
  146. package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +4 -4
  147. package/src/blocks/BlocksView.test.tsx +1101 -2
  148. package/src/blocks/BlocksView.tsx +5 -1
  149. package/src/blocks/blockRenderers.tsx +730 -22
  150. package/src/blocks/useChecklistState.ts +46 -0
  151. package/src/blocks/useResolvedImages.ts +16 -0
  152. package/src/bunSetup.ts +3 -0
  153. package/src/colorContrast.test.ts +27 -0
  154. package/src/colorContrast.ts +55 -0
  155. package/src/icons/OfflineIcon.tsx +2 -2
  156. package/src/icons/__snapshots__/OfflineIcon.test.tsx.snap +4 -4
  157. package/src/login/__snapshots__/LoginScreen.test.tsx.snap +7 -7
  158. package/src/signUp/__snapshots__/OAuthButtons.test.tsx.snap +3 -3
  159. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +7 -7
  160. package/src/table/TableDate.tsx +3 -1
  161. package/src/table/__snapshots__/Table.test.tsx.snap +5 -5
  162. package/src/table/__snapshots__/TableBadge.test.tsx.snap +3 -3
  163. package/src/table/__snapshots__/TableDate.test.tsx.snap +4 -0
  164. package/src/table/__snapshots__/TableHeader.test.tsx.snap +4 -4
  165. package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +7 -7
  166. package/src/table/__snapshots__/TableRow.test.tsx.snap +6 -6
@@ -5,9 +5,12 @@ import {Badge} from "./Badge";
5
5
  import type {SegmentedControlProps} from "./Common";
6
6
  import {Heading} from "./Heading";
7
7
  import {Icon} from "./Icon";
8
+ import {Text} from "./Text";
8
9
  import {useTheme} from "./Theme";
9
10
  import {resolveSegmentedControlTestIDsFromProps} from "./testing/resolveTestId";
10
11
 
12
+ const HEIGHT_BY_SIZE = {lg: 44, md: 36, sm: 28} as const;
13
+
11
14
  export const SegmentedControl: FC<SegmentedControlProps> = ({
12
15
  items,
13
16
  onChange = () => {},
@@ -18,7 +21,8 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
18
21
  testID,
19
22
  testIDs,
20
23
  }) => {
21
- const height = size === "md" ? 36 : 44;
24
+ const height = HEIGHT_BY_SIZE[size];
25
+ const hugsContent = size === "sm";
22
26
  const {theme} = useTheme();
23
27
  const segmentedControlTestIDs = resolveSegmentedControlTestIDsFromProps({testID, testIDs});
24
28
  const [startIndex, setStartIndex] = useState(0);
@@ -58,18 +62,19 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
58
62
  <Icon
59
63
  color={canScrollLeft ? "linkLight" : "extraLight"}
60
64
  iconName="chevron-left"
61
- size="lg"
65
+ size={hugsContent ? "sm" : "lg"}
62
66
  />
63
67
  </Pressable>
64
68
  )}
65
69
  <View
66
70
  style={{
67
71
  alignItems: "center",
68
- backgroundColor: theme.primitives.neutral300,
72
+ ...(hugsContent ? {alignSelf: "flex-start" as const} : {}),
73
+ backgroundColor: theme.surface.neutralLight,
69
74
  borderRadius: theme.primitives.radius3xl,
70
75
  display: "flex",
71
76
  flexDirection: "row",
72
- flexGrow: 1,
77
+ flexGrow: hugsContent ? 0 : 1,
73
78
  flexShrink: 1,
74
79
  height,
75
80
  maxHeight: height,
@@ -80,10 +85,10 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
80
85
  style={{
81
86
  display: "flex",
82
87
  flexDirection: "row",
83
- flexGrow: 1,
88
+ flexGrow: hugsContent ? 0 : 1,
84
89
  gap: 4,
85
90
  height: height - 4,
86
- paddingHorizontal: 4,
91
+ paddingHorizontal: hugsContent ? 2 : 4,
87
92
  }}
88
93
  >
89
94
  {visibleItems.map((item, index) => {
@@ -98,17 +103,23 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
98
103
  backgroundColor: actualIndex === selectedIndex ? theme.surface.base : undefined,
99
104
  borderRadius: theme.primitives.radius3xl,
100
105
  display: "flex",
101
- flexBasis: 0,
106
+ flexBasis: hugsContent ? "auto" : 0,
102
107
  flexDirection: "row",
103
- flexGrow: 1,
108
+ flexGrow: hugsContent ? 0 : 1,
104
109
  gap: 8,
105
110
  height: "100%",
106
111
  justifyContent: "center",
107
112
  overflow: "hidden",
108
- paddingHorizontal: 2,
113
+ paddingHorizontal: hugsContent ? 12 : 2,
109
114
  }}
110
115
  >
111
- <Heading size="sm">{item}</Heading>
116
+ {hugsContent ? (
117
+ <Text size="sm" skipLinking>
118
+ {item}
119
+ </Text>
120
+ ) : (
121
+ <Heading size="sm">{item}</Heading>
122
+ )}
112
123
  {visibleBadges[index] && (
113
124
  <Badge
114
125
  status={visibleBadges[index].status ?? "info"}
@@ -130,7 +141,7 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
130
141
  <Icon
131
142
  color={canScrollRight ? "linkLight" : "extraLight"}
132
143
  iconName="chevron-right"
133
- size="lg"
144
+ size={hugsContent ? "sm" : "lg"}
134
145
  />
135
146
  </Pressable>
136
147
  )}
@@ -44,7 +44,10 @@ export const SelectField: FC<SelectFieldProps> = ({
44
44
  }}
45
45
  placeholder={!requireValue ? clearOption : {}}
46
46
  renderMenuInBodyPortal={renderMenuInBodyPortal}
47
- textInputProps={{testID: fieldTestIDs.input}}
47
+ textInputProps={{
48
+ accessibilityLabel: title ?? placeholder,
49
+ testID: fieldTestIDs.input,
50
+ }}
48
51
  value={value ?? ""}
49
52
  />
50
53
  </View>
@@ -150,7 +150,7 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
150
150
  return (
151
151
  <Box
152
152
  avoidKeyboard
153
- color={color || "neutralLight"}
153
+ color={color || "baseAlternate"}
154
154
  flex="grow"
155
155
  height="100%"
156
156
  keyboardOffset={keyboardOffset}
@@ -1,10 +1,10 @@
1
1
  import {afterAll, afterEach, beforeEach, describe, expect, it, mock, spyOn} from "bun:test";
2
2
  import {act, fireEvent} from "@testing-library/react-native";
3
- import {forwardRef, type ReactNode, type Ref, useImperativeHandle} from "react";
4
- import {type ScaledSize, StyleSheet, useWindowDimensions, View} from "react-native";
3
+ import {forwardRef, type ReactElement, type ReactNode, type Ref, useImperativeHandle} from "react";
4
+ import {type ScaledSize, ScrollView, StyleSheet, useWindowDimensions, View} from "react-native";
5
5
  import type {ReactTestInstance} from "react-test-renderer";
6
6
 
7
- import {getRounding} from "./Common";
7
+ import {getRounding, getSpacing} from "./Common";
8
8
  import {SplitPage} from "./SplitPage";
9
9
  import {renderWithTheme} from "./test-utils";
10
10
 
@@ -20,11 +20,15 @@ const swiperScrollToIndex = mock((_options?: PagerScrollOptions) => {});
20
20
  mock.module("react-native-swiper-flatlist", () => ({
21
21
  SwiperFlatList: forwardRef(
22
22
  (
23
- {children}: {children?: ReactNode},
23
+ {children, style}: {children?: ReactNode; style?: object},
24
24
  ref: Ref<{scrollToIndex: (options: PagerScrollOptions) => void}>
25
25
  ) => {
26
26
  useImperativeHandle(ref, () => ({scrollToIndex: swiperScrollToIndex}));
27
- return <View testID="swiper-flatlist">{children}</View>;
27
+ return (
28
+ <View style={style} testID="swiper-flatlist">
29
+ {children}
30
+ </View>
31
+ );
28
32
  }
29
33
  ),
30
34
  }));
@@ -53,6 +57,10 @@ const styleWidth = (style: unknown): unknown => StyleSheet.flatten(style)?.width
53
57
 
54
58
  const styleBorderRadius = (style: unknown): unknown => StyleSheet.flatten(style)?.borderRadius;
55
59
 
60
+ const flattenedStyle = (style: unknown): ReturnType<typeof StyleSheet.flatten> => {
61
+ return StyleSheet.flatten(style) ?? {};
62
+ };
63
+
56
64
  const setDesktop = () => {
57
65
  mock.module("./MediaQuery", () => ({
58
66
  isNarrowViewport: () => false,
@@ -1074,4 +1082,464 @@ describe("SplitPage", () => {
1074
1082
  );
1075
1083
  });
1076
1084
  });
1085
+
1086
+ describe("desktop child column scrolling", () => {
1087
+ const tallChild = (testID: string): ReactElement => {
1088
+ return <View style={{height: 4000}} testID={testID} />;
1089
+ };
1090
+
1091
+ const renderFullHeightChild = (): ReactElement => {
1092
+ return (
1093
+ <View style={{height: "100%"}} testID="bounded-child">
1094
+ <View style={{height: 48}} testID="fixed-section" />
1095
+ <ScrollView testID="internal-scroll">
1096
+ <View style={{height: 4000}} testID="internal-tall" />
1097
+ </ScrollView>
1098
+ </View>
1099
+ );
1100
+ };
1101
+
1102
+ const expectClippingPane = (
1103
+ pane: ReactTestInstance,
1104
+ borderRadius: number,
1105
+ width: number | string
1106
+ ): void => {
1107
+ const style = flattenedStyle(pane.props.style);
1108
+ expect(style.borderRadius).toBe(borderRadius);
1109
+ expect(style.height).toBe("100%");
1110
+ expect(style.overflow).toBe("hidden");
1111
+ expect(style.width).toBe(width);
1112
+ };
1113
+
1114
+ const expectVerticalChildScroll = (scroll: ReactTestInstance, tallTestID: string): void => {
1115
+ const style = flattenedStyle(scroll.props.style);
1116
+ expect(style.overflow).toBeUndefined();
1117
+ expect(style.flex).toBe(1);
1118
+ expect(style.height).toBe("100%");
1119
+ expect(scroll.props.horizontal).toBeFalsy();
1120
+ expect(scroll.props.contentContainerStyle).toEqual({flex: 1});
1121
+ expect(scroll.findByProps({testID: tallTestID})).toBeTruthy();
1122
+ };
1123
+
1124
+ const expectBoundedFullHeightChild = (scroll: ReactTestInstance): void => {
1125
+ const child = scroll.findByProps({testID: "bounded-child"});
1126
+ const childStyle = flattenedStyle(child.props.style);
1127
+ expect(childStyle.height).toBe("100%");
1128
+ expect(childStyle.position).toBeUndefined();
1129
+ expect(scroll.props.contentContainerStyle).toEqual({flex: 1});
1130
+ expect(child.findByProps({testID: "fixed-section"})).toBeTruthy();
1131
+ expect(child.findByProps({testID: "internal-scroll"})).toBeTruthy();
1132
+ expect(child.findByProps({testID: "internal-tall"})).toBeTruthy();
1133
+ };
1134
+
1135
+ it("scrolls ordinary tall content in desktopChildrenMinWidth columns and keeps the pane clipped", () => {
1136
+ setDesktop();
1137
+ const {getByTestId} = renderWithTheme(
1138
+ <SplitPage {...defaultProps} desktopChildrenMinWidth={200}>
1139
+ {tallChild("tall-0")}
1140
+ {tallChild("tall-1")}
1141
+ </SplitPage>
1142
+ );
1143
+
1144
+ expectClippingPane(getByTestId("split-page-desktop-child-0"), getRounding("md"), 200);
1145
+ expectClippingPane(getByTestId("split-page-desktop-child-1"), getRounding("md"), 200);
1146
+ expectVerticalChildScroll(getByTestId("split-page-desktop-child-scroll-0"), "tall-0");
1147
+ expectVerticalChildScroll(getByTestId("split-page-desktop-child-scroll-1"), "tall-1");
1148
+ expect(
1149
+ flattenedStyle(getByTestId("split-page-desktop-children-scroll").props.style).overflow
1150
+ ).toBeUndefined();
1151
+ });
1152
+
1153
+ it("scrolls ordinary tall content in the default one and two child row", () => {
1154
+ setDesktop();
1155
+ const {getByTestId} = renderWithTheme(
1156
+ <SplitPage {...defaultProps}>
1157
+ {tallChild("tall-0")}
1158
+ {tallChild("tall-1")}
1159
+ </SplitPage>
1160
+ );
1161
+
1162
+ expectClippingPane(getByTestId("split-page-desktop-row-child-0"), getRounding("md"), "60%");
1163
+ expectClippingPane(getByTestId("split-page-desktop-row-child-1"), getRounding("md"), "60%");
1164
+ expect(flattenedStyle(getByTestId("split-page-desktop-row-child-0").props.style).flex).toBe(
1165
+ 1
1166
+ );
1167
+ expectVerticalChildScroll(getByTestId("split-page-desktop-child-scroll-0"), "tall-0");
1168
+ expectVerticalChildScroll(getByTestId("split-page-desktop-child-scroll-1"), "tall-1");
1169
+ });
1170
+
1171
+ it("scrolls ordinary tall content in the segmented layout", () => {
1172
+ setDesktop();
1173
+ const {getByTestId} = renderWithTheme(
1174
+ <SplitPage {...defaultProps} tabs={["One", "Two", "Three"]}>
1175
+ {tallChild("tall-0")}
1176
+ {tallChild("tall-1")}
1177
+ {tallChild("tall-2")}
1178
+ </SplitPage>
1179
+ );
1180
+
1181
+ expectClippingPane(
1182
+ getByTestId("split-page-desktop-segment-child-0"),
1183
+ getRounding("md"),
1184
+ "60%"
1185
+ );
1186
+ expectClippingPane(
1187
+ getByTestId("split-page-desktop-segment-child-1"),
1188
+ getRounding("md"),
1189
+ "60%"
1190
+ );
1191
+ expect(
1192
+ flattenedStyle(getByTestId("split-page-desktop-segment-child-0").props.style).paddingRight
1193
+ ).toBe(16);
1194
+ expect(
1195
+ flattenedStyle(getByTestId("split-page-desktop-segment-child-1").props.style).paddingLeft
1196
+ ).toBe(16);
1197
+ expectVerticalChildScroll(getByTestId("split-page-desktop-child-scroll-0"), "tall-0");
1198
+ expectVerticalChildScroll(getByTestId("split-page-desktop-child-scroll-1"), "tall-1");
1199
+ });
1200
+
1201
+ it("preserves a custom childColumnRounding on every desktop child layout", () => {
1202
+ setDesktop();
1203
+ const minWidth = renderWithTheme(
1204
+ <SplitPage {...defaultProps} childColumnRounding="lg" desktopChildrenMinWidth={220}>
1205
+ <View testID="child-1" />
1206
+ <View testID="child-2" />
1207
+ </SplitPage>
1208
+ );
1209
+ expect(
1210
+ styleBorderRadius(minWidth.getByTestId("split-page-desktop-child-0").props.style)
1211
+ ).toBe(getRounding("lg"));
1212
+
1213
+ const row = renderWithTheme(
1214
+ <SplitPage {...defaultProps} childColumnRounding="sm">
1215
+ <View testID="child-1" />
1216
+ </SplitPage>
1217
+ );
1218
+ expect(styleBorderRadius(row.getByTestId("split-page-desktop-row-child-0").props.style)).toBe(
1219
+ getRounding("sm")
1220
+ );
1221
+
1222
+ const segmented = renderWithTheme(
1223
+ <SplitPage {...defaultProps} childColumnRounding="xl" tabs={["One", "Two", "Three"]}>
1224
+ <View testID="child-1" />
1225
+ <View testID="child-2" />
1226
+ <View testID="child-3" />
1227
+ </SplitPage>
1228
+ );
1229
+ expect(
1230
+ styleBorderRadius(segmented.getByTestId("split-page-desktop-segment-child-0").props.style)
1231
+ ).toBe(getRounding("xl"));
1232
+ });
1233
+
1234
+ it("keeps a height 100% child bounded to the pane with its own scroll view", () => {
1235
+ setDesktop();
1236
+ const minWidth = renderWithTheme(
1237
+ <SplitPage {...defaultProps} desktopChildrenMinWidth={240}>
1238
+ {renderFullHeightChild()}
1239
+ <View testID="other-child" />
1240
+ </SplitPage>
1241
+ );
1242
+ const minWidthPane = minWidth.getByTestId("split-page-desktop-child-0");
1243
+ expect(flattenedStyle(minWidthPane.props.style).height).toBe("100%");
1244
+ expect(flattenedStyle(minWidthPane.props.style).overflow).toBe("hidden");
1245
+ expectBoundedFullHeightChild(minWidth.getByTestId("split-page-desktop-child-scroll-0"));
1246
+
1247
+ const row = renderWithTheme(
1248
+ <SplitPage {...defaultProps}>{renderFullHeightChild()}</SplitPage>
1249
+ );
1250
+ expectBoundedFullHeightChild(row.getByTestId("split-page-desktop-child-scroll-0"));
1251
+ expect(
1252
+ flattenedStyle(row.getByTestId("split-page-desktop-row-child-0").props.style).height
1253
+ ).toBe("100%");
1254
+
1255
+ const segmented = renderWithTheme(
1256
+ <SplitPage {...defaultProps} tabs={["One", "Two", "Three"]}>
1257
+ {renderFullHeightChild()}
1258
+ <View testID="child-2" />
1259
+ <View testID="child-3" />
1260
+ </SplitPage>
1261
+ );
1262
+ expectBoundedFullHeightChild(segmented.getByTestId("split-page-desktop-child-scroll-0"));
1263
+ expect(
1264
+ flattenedStyle(segmented.getByTestId("split-page-desktop-segment-child-0").props.style)
1265
+ .overflow
1266
+ ).toBe("hidden");
1267
+ });
1268
+ });
1269
+
1270
+ describe("narrow child column scrolling", () => {
1271
+ const renderFullHeightChild = (): ReactElement => {
1272
+ return (
1273
+ <View style={{height: "100%"}} testID="bounded-child">
1274
+ <View style={{height: 48}} testID="fixed-section" />
1275
+ <ScrollView testID="internal-scroll">
1276
+ <View style={{height: 4000}} testID="internal-tall" />
1277
+ </ScrollView>
1278
+ </View>
1279
+ );
1280
+ };
1281
+
1282
+ const selectFirst = async (
1283
+ getAllByLabelText: (label: string) => ReactTestInstance[]
1284
+ ): Promise<void> => {
1285
+ const boxes = getAllByLabelText("Select");
1286
+ await act(async () => {
1287
+ fireEvent.press(boxes[0]);
1288
+ });
1289
+ };
1290
+
1291
+ const layoutPager = (node: ReactTestInstance, height: number, width: number): void => {
1292
+ act(() => {
1293
+ node.props.onLayout({
1294
+ nativeEvent: {layout: {height, width, x: 0, y: 0}},
1295
+ });
1296
+ });
1297
+ };
1298
+
1299
+ const expectBoundedNarrowChild = (page: ReactTestInstance): void => {
1300
+ const child = page.findByProps({testID: "bounded-child"});
1301
+ const childStyle = flattenedStyle(child.props.style);
1302
+ expect(childStyle.height).toBe("100%");
1303
+ expect(childStyle.position).toBeUndefined();
1304
+ expect(page.findByProps({testID: "fixed-section"})).toBeTruthy();
1305
+ expect(page.findByProps({testID: "internal-scroll"})).toBeTruthy();
1306
+ expect(page.findByProps({testID: "internal-tall"})).toBeTruthy();
1307
+ };
1308
+
1309
+ it("bounds a labeled narrow page to the measured pane so a height 100% child can scroll inside it", async () => {
1310
+ setMobile();
1311
+ const {getAllByLabelText, getByTestId, UNSAFE_root} = renderWithTheme(
1312
+ <SplitPage
1313
+ {...defaultProps}
1314
+ bottomNavBarHeight={24}
1315
+ narrowViewportChildLabels={["Summary", "Notes"]}
1316
+ narrowViewportListButtonLabel="Back to list"
1317
+ >
1318
+ {renderFullHeightChild()}
1319
+ <View testID="other-child" />
1320
+ </SplitPage>
1321
+ );
1322
+ await selectFirst(getAllByLabelText);
1323
+ const pageBeforeLayout = getByTestId("split-page-mobile-child-0");
1324
+ expect(flattenedStyle(pageBeforeLayout.props.style).height).toBe("100%");
1325
+
1326
+ layoutPager(getByTestId("split-page-mobile-children"), 360, 320);
1327
+
1328
+ const page = getByTestId("split-page-mobile-child-0");
1329
+ const style = flattenedStyle(page.props.style);
1330
+ const edge = getSpacing(2);
1331
+ const navButton = 32;
1332
+ const bottomNav = 24;
1333
+ const columnHeight = 360 - (edge + edge + navButton + edge + bottomNav);
1334
+ expect(style.height).toBe(columnHeight);
1335
+ expect(style.overflow).toBe("hidden");
1336
+ expect(style.borderRadius).toBe(getRounding("md"));
1337
+ expect(style.paddingBottom).toBeUndefined();
1338
+ expect(style.width).toBe(320);
1339
+ expect(style.position).toBeUndefined();
1340
+ expectBoundedNarrowChild(page);
1341
+ expect(flattenedStyle(getByTestId("split-page-mobile-child-1").props.style).height).toBe(
1342
+ columnHeight
1343
+ );
1344
+ const swiper = flattenedStyle(getByTestId("swiper-flatlist").props.style);
1345
+ expect(swiper.height).toBe(columnHeight);
1346
+ expect(swiper.overflow).toBeUndefined();
1347
+ expect(flattenedStyle(getByTestId("split-page-column-top-space").props.style).height).toBe(
1348
+ edge
1349
+ );
1350
+
1351
+ const nav = getByTestId("split-page-column-nav");
1352
+ const navStyle = flattenedStyle(nav.props.style);
1353
+ expect(navStyle.position).toBeUndefined();
1354
+ expect(navStyle.flexDirection).toBe("row");
1355
+ expect(navStyle.justifyContent).toBe("space-between");
1356
+ expect(navStyle.height).toBe(navButton);
1357
+ expect(navStyle.marginTop).toBe(edge);
1358
+ expect(navStyle.paddingBottom).toBeUndefined();
1359
+ expect(navStyle.paddingHorizontal).toBe(getSpacing(4));
1360
+ expect(flattenedStyle(getByTestId("split-page-column-bottom-space").props.style).height).toBe(
1361
+ edge + bottomNav
1362
+ );
1363
+ expect(page.findAll((node) => node.props?.testID === "split-page-column-nav")).toHaveLength(
1364
+ 0
1365
+ );
1366
+
1367
+ const previousSlot = getByTestId("split-page-column-previous-slot");
1368
+ const nextSlot = getByTestId("split-page-column-next-slot");
1369
+ const slotStyle = {height: navButton, width: navButton};
1370
+ expect(flattenedStyle(previousSlot.props.style)).toMatchObject(slotStyle);
1371
+ expect(flattenedStyle(nextSlot.props.style)).toMatchObject(slotStyle);
1372
+ expect(previousSlot.props.accessible).toBe(false);
1373
+ expect(nextSlot.props.accessible).toBe(false);
1374
+ expect(queryIconButtonByTestId(UNSAFE_root, "split-page-column-previous")).toBeUndefined();
1375
+ expect(
1376
+ previousSlot.findAll((node) => node.props?.testID === "split-page-column-previous")
1377
+ ).toHaveLength(0);
1378
+ const next = getIconButtonByTestId(UNSAFE_root, "split-page-column-next");
1379
+ expect(next.props.accessibilityLabel).toBe("Show next column: Notes");
1380
+ expect(next.props.iconName).toBe("chevron-right");
1381
+ expect(
1382
+ nextSlot.findAll((node) => node.props?.testID === "split-page-column-next")
1383
+ ).toHaveLength(1);
1384
+ const back = getIconButtonByTestId(UNSAFE_root, "split-page-back-to-list");
1385
+ expect(
1386
+ findAncestor(back, (node) => flattenedStyle(node.props.style).position === "absolute")
1387
+ ).toBeUndefined();
1388
+ expect(findAncestor(back, (node) => node.props?.testID === "split-page-column-nav")).toBe(
1389
+ nav
1390
+ );
1391
+ expect(flattenedStyle(getByTestId("split-page-column-back-slot").props.style)).toMatchObject(
1392
+ slotStyle
1393
+ );
1394
+
1395
+ await act(async () => {
1396
+ next.props.onClick();
1397
+ });
1398
+ expect(queryIconButtonByTestId(UNSAFE_root, "split-page-column-next")).toBeUndefined();
1399
+ expect(
1400
+ getByTestId("split-page-column-next-slot").findAll(
1401
+ (node) => node.props?.testID === "split-page-column-next"
1402
+ )
1403
+ ).toHaveLength(0);
1404
+ const previous = getIconButtonByTestId(UNSAFE_root, "split-page-column-previous");
1405
+ expect(previous.props.accessibilityLabel).toBe("Show previous column: Summary");
1406
+ expect(previous.props.iconName).toBe("chevron-left");
1407
+ expect(
1408
+ getByTestId("split-page-column-previous-slot").findAll(
1409
+ (node) => node.props?.testID === "split-page-column-previous"
1410
+ )
1411
+ ).toHaveLength(1);
1412
+ expect(
1413
+ flattenedStyle(getByTestId("split-page-column-previous-slot").props.style)
1414
+ ).toMatchObject(slotStyle);
1415
+ expect(flattenedStyle(getByTestId("split-page-column-next-slot").props.style)).toMatchObject(
1416
+ slotStyle
1417
+ );
1418
+ expect(flattenedStyle(getByTestId("split-page-column-nav").props.style).height).toBe(
1419
+ navButton
1420
+ );
1421
+ expect(flattenedStyle(getByTestId("split-page-mobile-child-0").props.style).height).toBe(
1422
+ columnHeight
1423
+ );
1424
+ expect(flattenedStyle(getByTestId("split-page-mobile-child-1").props.style).height).toBe(
1425
+ columnHeight
1426
+ );
1427
+ });
1428
+
1429
+ it("keeps labeled nav slots stationary across the first, middle, and last columns", async () => {
1430
+ setMobile();
1431
+ const {getAllByLabelText, getByTestId, UNSAFE_root} = renderWithTheme(
1432
+ <SplitPage
1433
+ {...defaultProps}
1434
+ bottomNavBarHeight={20}
1435
+ narrowViewportChildLabels={["Summary", "Notes", "History"]}
1436
+ narrowViewportListButtonLabel="Back to list"
1437
+ tabs={["Summary", "Notes", "History"]}
1438
+ >
1439
+ <View testID="child-1" />
1440
+ <View testID="child-2" />
1441
+ <View testID="child-3" />
1442
+ </SplitPage>
1443
+ );
1444
+ await selectFirst(getAllByLabelText);
1445
+ layoutPager(getByTestId("split-page-mobile-children"), 500, 340);
1446
+
1447
+ const edge = getSpacing(2);
1448
+ const columnHeight = 500 - (edge + edge + 32 + edge + 20);
1449
+ const slotStyle = {height: 32, width: 32};
1450
+ const expectStationaryChrome = (): void => {
1451
+ expect(flattenedStyle(getByTestId("split-page-mobile-child-0").props.style).height).toBe(
1452
+ columnHeight
1453
+ );
1454
+ expect(flattenedStyle(getByTestId("split-page-mobile-child-1").props.style).height).toBe(
1455
+ columnHeight
1456
+ );
1457
+ expect(flattenedStyle(getByTestId("split-page-mobile-child-2").props.style).height).toBe(
1458
+ columnHeight
1459
+ );
1460
+ expect(flattenedStyle(getByTestId("split-page-column-nav").props.style)).toMatchObject({
1461
+ height: 32,
1462
+ marginTop: edge,
1463
+ });
1464
+ expect(
1465
+ flattenedStyle(getByTestId("split-page-column-previous-slot").props.style)
1466
+ ).toMatchObject(slotStyle);
1467
+ expect(
1468
+ flattenedStyle(getByTestId("split-page-column-next-slot").props.style)
1469
+ ).toMatchObject(slotStyle);
1470
+ expect(
1471
+ flattenedStyle(getByTestId("split-page-column-back-slot").props.style)
1472
+ ).toMatchObject(slotStyle);
1473
+ expect(
1474
+ flattenedStyle(getByTestId("split-page-column-bottom-space").props.style).height
1475
+ ).toBe(edge + 20);
1476
+ };
1477
+
1478
+ expectStationaryChrome();
1479
+ expect(queryIconButtonByTestId(UNSAFE_root, "split-page-column-previous")).toBeUndefined();
1480
+ expect(getIconButtonByTestId(UNSAFE_root, "split-page-column-next").props.iconName).toBe(
1481
+ "chevron-right"
1482
+ );
1483
+
1484
+ await act(async () => {
1485
+ getIconButtonByTestId(UNSAFE_root, "split-page-column-next").props.onClick();
1486
+ });
1487
+ expectStationaryChrome();
1488
+ expect(getIconButtonByTestId(UNSAFE_root, "split-page-column-previous").props.iconName).toBe(
1489
+ "chevron-left"
1490
+ );
1491
+ expect(
1492
+ getIconButtonByTestId(UNSAFE_root, "split-page-column-next").props.accessibilityLabel
1493
+ ).toBe("Show next column: History");
1494
+
1495
+ await act(async () => {
1496
+ getIconButtonByTestId(UNSAFE_root, "split-page-column-next").props.onClick();
1497
+ });
1498
+ expectStationaryChrome();
1499
+ expect(queryIconButtonByTestId(UNSAFE_root, "split-page-column-next")).toBeUndefined();
1500
+ expect(
1501
+ getIconButtonByTestId(UNSAFE_root, "split-page-column-previous").props.accessibilityLabel
1502
+ ).toBe("Show previous column: Notes");
1503
+ });
1504
+
1505
+ it("bounds dotted narrow pages to the measured pane and keeps pagination room", async () => {
1506
+ setMobile();
1507
+ const {getAllByLabelText, getByTestId} = renderWithTheme(
1508
+ <SplitPage {...defaultProps} bottomNavBarHeight={16} childColumnRounding="lg">
1509
+ {renderFullHeightChild()}
1510
+ <View testID="other-child" />
1511
+ </SplitPage>
1512
+ );
1513
+ await selectFirst(getAllByLabelText);
1514
+ expect(flattenedStyle(getByTestId("split-page-dotted-child-0").props.style).height).toBe(
1515
+ "90%"
1516
+ );
1517
+
1518
+ layoutPager(getByTestId("split-page-dotted-pager"), 400, 300);
1519
+
1520
+ const page = getByTestId("split-page-dotted-child-0");
1521
+ const style = flattenedStyle(page.props.style);
1522
+ expect(style.height).toBe(360);
1523
+ expect(style.overflow).toBe("hidden");
1524
+ expect(style.borderRadius).toBe(getRounding("lg"));
1525
+ expect(style.paddingBottom).toBe(16);
1526
+ expect(style.padding).toBe(4);
1527
+ expect(style.width).toBe(367);
1528
+ expectBoundedNarrowChild(page);
1529
+ const swiper = flattenedStyle(getByTestId("swiper-flatlist").props.style);
1530
+ expect(swiper.height).toBe("100%");
1531
+ expect(swiper.overflow).toBeUndefined();
1532
+ });
1533
+
1534
+ it("bounds a single dotted page to the full measured height", async () => {
1535
+ setMobile();
1536
+ const {getAllByLabelText, getByTestId} = renderWithTheme(
1537
+ <SplitPage {...defaultProps}>{renderFullHeightChild()}</SplitPage>
1538
+ );
1539
+ await selectFirst(getAllByLabelText);
1540
+ layoutPager(getByTestId("split-page-dotted-pager"), 410, 300);
1541
+ expect(flattenedStyle(getByTestId("split-page-dotted-child-0").props.style).height).toBe(410);
1542
+ expectBoundedNarrowChild(getByTestId("split-page-dotted-child-0"));
1543
+ });
1544
+ });
1077
1545
  });