@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.
- package/dist/AiSuggestionBox.js +9 -9
- package/dist/AiSuggestionBox.js.map +1 -1
- package/dist/Banner.js +1 -1
- package/dist/Banner.js.map +1 -1
- package/dist/Box.d.ts.map +1 -1
- package/dist/Box.js +36 -3
- package/dist/Box.js.map +1 -1
- package/dist/Button.d.ts.map +1 -1
- package/dist/Button.js +7 -0
- package/dist/Button.js.map +1 -1
- package/dist/Common.d.ts +34 -4
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/DataTable.d.ts.map +1 -1
- package/dist/DataTable.js +50 -3
- package/dist/DataTable.js.map +1 -1
- package/dist/Image.d.ts.map +1 -1
- package/dist/Image.js +1 -1
- package/dist/Image.js.map +1 -1
- package/dist/MarkdownView.d.ts.map +1 -1
- package/dist/MarkdownView.js +67 -5
- package/dist/MarkdownView.js.map +1 -1
- package/dist/Modal.js +1 -1
- package/dist/SegmentedControl.d.ts.map +1 -1
- package/dist/SegmentedControl.js +15 -11
- package/dist/SegmentedControl.js.map +1 -1
- package/dist/SelectField.d.ts.map +1 -1
- package/dist/SelectField.js +4 -1
- package/dist/SelectField.js.map +1 -1
- package/dist/SplitPage.d.ts.map +1 -1
- package/dist/SplitPage.js +145 -55
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.js +1 -1
- package/dist/SplitPage.native.js.map +1 -1
- package/dist/TerrenoProvider.d.ts +7 -3
- package/dist/TerrenoProvider.d.ts.map +1 -1
- package/dist/TerrenoProvider.js +2 -2
- package/dist/TerrenoProvider.js.map +1 -1
- package/dist/Theme.d.ts +19 -85
- package/dist/Theme.d.ts.map +1 -1
- package/dist/Theme.js +149 -33
- package/dist/Theme.js.map +1 -1
- package/dist/Toast.d.ts.map +1 -1
- package/dist/Toast.js +21 -12
- package/dist/Toast.js.map +1 -1
- package/dist/ToastNotifications.d.ts.map +1 -1
- package/dist/ToastNotifications.js +5 -2
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/Tooltip.d.ts +1 -0
- package/dist/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip.js +84 -37
- package/dist/Tooltip.js.map +1 -1
- package/dist/blocks/BlocksView.d.ts.map +1 -1
- package/dist/blocks/BlocksView.js +5 -1
- package/dist/blocks/BlocksView.js.map +1 -1
- package/dist/blocks/blockRenderers.d.ts +10 -1
- package/dist/blocks/blockRenderers.d.ts.map +1 -1
- package/dist/blocks/blockRenderers.js +330 -9
- package/dist/blocks/blockRenderers.js.map +1 -1
- package/dist/blocks/useChecklistState.d.ts +18 -0
- package/dist/blocks/useChecklistState.d.ts.map +1 -0
- package/dist/blocks/useChecklistState.js +29 -0
- package/dist/blocks/useChecklistState.js.map +1 -0
- package/dist/blocks/useResolvedImages.d.ts.map +1 -1
- package/dist/blocks/useResolvedImages.js +16 -0
- package/dist/blocks/useResolvedImages.js.map +1 -1
- package/dist/colorContrast.d.ts +9 -0
- package/dist/colorContrast.d.ts.map +1 -0
- package/dist/colorContrast.js +47 -0
- package/dist/colorContrast.js.map +1 -0
- package/dist/icons/OfflineIcon.js +1 -1
- package/dist/table/TableDate.d.ts.map +1 -1
- package/dist/table/TableDate.js +3 -1
- package/dist/table/TableDate.js.map +1 -1
- package/package.json +2 -2
- package/src/AiSuggestionBox.tsx +10 -10
- package/src/Banner.tsx +1 -1
- package/src/Box.test.tsx +80 -0
- package/src/Box.tsx +52 -0
- package/src/Button.test.tsx +39 -1
- package/src/Button.tsx +9 -0
- package/src/Common.ts +35 -4
- package/src/DataTable.test.tsx +133 -1
- package/src/DataTable.tsx +78 -3
- package/src/Image.tsx +1 -0
- package/src/MarkdownView.test.tsx +165 -2
- package/src/MarkdownView.tsx +100 -5
- package/src/Modal.tsx +1 -1
- package/src/SegmentedControl.test.tsx +7 -0
- package/src/SegmentedControl.tsx +22 -11
- package/src/SelectField.tsx +4 -1
- package/src/SplitPage.native.tsx +1 -1
- package/src/SplitPage.test.tsx +473 -5
- package/src/SplitPage.tsx +266 -132
- package/src/TerrenoProvider.tsx +15 -5
- package/src/Theme.test.tsx +212 -3
- package/src/Theme.tsx +184 -39
- package/src/Toast.test.tsx +7 -0
- package/src/Toast.tsx +22 -12
- package/src/ToastNotifications.test.tsx +36 -0
- package/src/ToastNotifications.tsx +5 -2
- package/src/Tooltip.test.tsx +232 -1
- package/src/Tooltip.tsx +128 -67
- package/src/__snapshots__/AddressField.test.tsx.snap +7 -7
- package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +23 -23
- package/src/__snapshots__/Banner.test.tsx.snap +3 -0
- package/src/__snapshots__/BooleanField.test.tsx.snap +3 -3
- package/src/__snapshots__/Button.test.tsx.snap +16 -16
- package/src/__snapshots__/Card.test.tsx.snap +0 -1
- package/src/__snapshots__/CustomSelectField.test.tsx.snap +23 -23
- package/src/__snapshots__/DataTable.test.tsx.snap +30 -30
- package/src/__snapshots__/DecimalRangeActionSheet.test.tsx.snap +2 -2
- package/src/__snapshots__/DropdownPanel.test.tsx.snap +2 -2
- package/src/__snapshots__/EmailField.test.tsx.snap +2 -2
- package/src/__snapshots__/ErrorPage.test.tsx.snap +1 -1
- package/src/__snapshots__/Field.test.tsx.snap +37 -37
- package/src/__snapshots__/FilterSelectMenu.test.tsx.snap +2 -1
- package/src/__snapshots__/HeightActionSheet.test.tsx.snap +2 -2
- package/src/__snapshots__/HeightField.test.tsx.snap +8 -8
- package/src/__snapshots__/HeightFieldDesktop.test.tsx.snap +6 -6
- package/src/__snapshots__/InfoModalIcon.test.tsx.snap +2 -2
- package/src/__snapshots__/MarkdownView.test.tsx.snap +2 -2
- package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +1 -1
- package/src/__snapshots__/Modal.test.tsx.snap +10 -10
- package/src/__snapshots__/NumberField.test.tsx.snap +1 -1
- package/src/__snapshots__/NumberPickerActionSheet.test.tsx.snap +2 -2
- package/src/__snapshots__/Page.test.tsx.snap +1 -1
- package/src/__snapshots__/PhoneNumberField.test.tsx.snap +4 -4
- package/src/__snapshots__/PickerSelect.test.tsx.snap +8 -8
- package/src/__snapshots__/SectionDivider.test.tsx.snap +2 -2
- package/src/__snapshots__/SegmentedControl.test.tsx.snap +183 -0
- package/src/__snapshots__/SelectBadge.test.tsx.snap +9 -9
- package/src/__snapshots__/SelectField.test.tsx.snap +19 -19
- package/src/__snapshots__/Signature.test.tsx.snap +1 -1
- package/src/__snapshots__/SignatureCaptureField.test.tsx.snap +2 -2
- package/src/__snapshots__/SignatureField.test.tsx.snap +2 -2
- package/src/__snapshots__/SplitPage.test.tsx.snap +165 -67
- package/src/__snapshots__/TapToEdit.test.tsx.snap +1 -1
- package/src/__snapshots__/TerrenoProvider.test.tsx.snap +20 -4
- package/src/__snapshots__/TextArea.test.tsx.snap +4 -4
- package/src/__snapshots__/TextField.test.tsx.snap +3 -3
- package/src/__snapshots__/TimezonePicker.test.tsx.snap +18 -18
- package/src/__snapshots__/Toast.test.tsx.snap +224 -154
- package/src/__snapshots__/TypedSignatureField.test.tsx.snap +3 -3
- package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +6 -6
- package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +4 -4
- package/src/blocks/BlocksView.test.tsx +1101 -2
- package/src/blocks/BlocksView.tsx +5 -1
- package/src/blocks/blockRenderers.tsx +730 -22
- package/src/blocks/useChecklistState.ts +46 -0
- package/src/blocks/useResolvedImages.ts +16 -0
- package/src/bunSetup.ts +3 -0
- package/src/colorContrast.test.ts +27 -0
- package/src/colorContrast.ts +55 -0
- package/src/icons/OfflineIcon.tsx +2 -2
- package/src/icons/__snapshots__/OfflineIcon.test.tsx.snap +4 -4
- package/src/login/__snapshots__/LoginScreen.test.tsx.snap +7 -7
- package/src/signUp/__snapshots__/OAuthButtons.test.tsx.snap +3 -3
- package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +7 -7
- package/src/table/TableDate.tsx +3 -1
- package/src/table/__snapshots__/Table.test.tsx.snap +5 -5
- package/src/table/__snapshots__/TableBadge.test.tsx.snap +3 -3
- package/src/table/__snapshots__/TableDate.test.tsx.snap +4 -0
- package/src/table/__snapshots__/TableHeader.test.tsx.snap +4 -4
- package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +7 -7
- package/src/table/__snapshots__/TableRow.test.tsx.snap +6 -6
package/src/SplitPage.tsx
CHANGED
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
Children,
|
|
3
3
|
type ComponentProps,
|
|
4
4
|
type ElementRef,
|
|
5
|
+
type ReactElement,
|
|
6
|
+
type ReactNode,
|
|
5
7
|
useCallback,
|
|
6
8
|
useEffect,
|
|
7
9
|
useRef,
|
|
@@ -13,11 +15,12 @@ import {
|
|
|
13
15
|
ScrollView,
|
|
14
16
|
useWindowDimensions,
|
|
15
17
|
View,
|
|
18
|
+
type ViewStyle,
|
|
16
19
|
} from "react-native";
|
|
17
20
|
import {SwiperFlatList} from "react-native-swiper-flatlist";
|
|
18
21
|
|
|
19
22
|
import {Box} from "./Box";
|
|
20
|
-
import {getRounding, type SplitPageListItem, type SplitPageProps} from "./Common";
|
|
23
|
+
import {getRounding, getSpacing, type SplitPageListItem, type SplitPageProps} from "./Common";
|
|
21
24
|
import {FlatList} from "./FlatList";
|
|
22
25
|
import {IconButton} from "./IconButton";
|
|
23
26
|
import {isNarrowViewport} from "./MediaQuery";
|
|
@@ -25,6 +28,54 @@ import {SegmentedControl} from "./SegmentedControl";
|
|
|
25
28
|
import {Spinner} from "./Spinner";
|
|
26
29
|
import {useTheme} from "./Theme";
|
|
27
30
|
|
|
31
|
+
// flex: 1 (basis 0, shrink 1) sizes the content container to the pane. A height: "100%"
|
|
32
|
+
// child then stays pane-bounded and can scroll internally. A taller child that does not
|
|
33
|
+
// shrink still extends this ScrollView. flexGrow: 1 leaves the basis at the content size,
|
|
34
|
+
// so that same height: "100%" child grows with its content instead of the pane.
|
|
35
|
+
const desktopChildContentContainerStyle = {flex: 1};
|
|
36
|
+
|
|
37
|
+
// Matches IconButton's default box. The labeled pager reserves this slot even when the
|
|
38
|
+
// arrow is hidden, so the other arrow does not reflow.
|
|
39
|
+
const labeledColumnNavButtonHeight = 32;
|
|
40
|
+
const labeledPagerEdgeSpacing = getSpacing(2);
|
|
41
|
+
|
|
42
|
+
const renderDesktopChildColumn = ({
|
|
43
|
+
borderRadius,
|
|
44
|
+
columnKey,
|
|
45
|
+
element,
|
|
46
|
+
paneStyle,
|
|
47
|
+
scrollTestID,
|
|
48
|
+
testID,
|
|
49
|
+
}: {
|
|
50
|
+
borderRadius: number;
|
|
51
|
+
columnKey: number;
|
|
52
|
+
element: ReactNode;
|
|
53
|
+
paneStyle: ViewStyle;
|
|
54
|
+
scrollTestID: string;
|
|
55
|
+
testID: string;
|
|
56
|
+
}): ReactElement => {
|
|
57
|
+
return (
|
|
58
|
+
<View
|
|
59
|
+
key={columnKey}
|
|
60
|
+
style={{
|
|
61
|
+
...paneStyle,
|
|
62
|
+
borderRadius,
|
|
63
|
+
height: "100%",
|
|
64
|
+
overflow: "hidden",
|
|
65
|
+
}}
|
|
66
|
+
testID={testID}
|
|
67
|
+
>
|
|
68
|
+
<ScrollView
|
|
69
|
+
contentContainerStyle={desktopChildContentContainerStyle}
|
|
70
|
+
style={{flex: 1, height: "100%"}}
|
|
71
|
+
testID={scrollTestID}
|
|
72
|
+
>
|
|
73
|
+
{element}
|
|
74
|
+
</ScrollView>
|
|
75
|
+
</View>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
28
79
|
// A component for rendering a list on one side and a details view on the right for large screens,
|
|
29
80
|
// and a scrollable list where clicking an item takes you the details view.
|
|
30
81
|
// On web, opt in to minimum widths for the desktop side-by-side children, or a labeled pager
|
|
@@ -62,8 +113,10 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
62
113
|
const activeChildIndexRef = useRef(activeChildIndex);
|
|
63
114
|
activeChildIndexRef.current = activeChildIndex;
|
|
64
115
|
const swiperRef = useRef<ElementRef<typeof SwiperFlatList> | null>(null);
|
|
116
|
+
const narrowPagerRef = useRef<ElementRef<typeof View> | null>(null);
|
|
65
117
|
const [desktopScrollWidth, setDesktopScrollWidth] = useState(0);
|
|
66
118
|
const [measuredPageWidth, setMeasuredPageWidth] = useState(0);
|
|
119
|
+
const [measuredPageHeight, setMeasuredPageHeight] = useState(0);
|
|
67
120
|
|
|
68
121
|
const isNarrowLayout =
|
|
69
122
|
narrowBelowWidth === undefined ? isNarrowViewport() : windowWidth <= narrowBelowWidth;
|
|
@@ -109,6 +162,50 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
109
162
|
});
|
|
110
163
|
}, [measuredPageWidth, windowWidth]);
|
|
111
164
|
|
|
165
|
+
const rememberNarrowPagerSize = useCallback((width: number, height: number): void => {
|
|
166
|
+
if (width > 0) {
|
|
167
|
+
setMeasuredPageWidth((current) => (current === width ? current : width));
|
|
168
|
+
}
|
|
169
|
+
if (height > 0) {
|
|
170
|
+
setMeasuredPageHeight((current) => (current === height ? current : height));
|
|
171
|
+
}
|
|
172
|
+
}, []);
|
|
173
|
+
|
|
174
|
+
const onNarrowPagerLayout = useCallback(
|
|
175
|
+
(event: LayoutChangeEvent): void => {
|
|
176
|
+
const {height, width} = event.nativeEvent.layout;
|
|
177
|
+
rememberNarrowPagerSize(width, height);
|
|
178
|
+
},
|
|
179
|
+
[rememberNarrowPagerSize]
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
// The pager frame is already the visible height. Reading it here covers the case where
|
|
183
|
+
// the view's onLayout callback does not run after the frame settles.
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
if (!isNarrowLayout || !isDetailActive) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const node = narrowPagerRef.current as unknown as HTMLElement | null;
|
|
189
|
+
if (
|
|
190
|
+
node == null ||
|
|
191
|
+
typeof node.offsetHeight !== "number" ||
|
|
192
|
+
typeof ResizeObserver === "undefined"
|
|
193
|
+
) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const measure = (): void => {
|
|
197
|
+
rememberNarrowPagerSize(node.offsetWidth, node.offsetHeight);
|
|
198
|
+
};
|
|
199
|
+
measure();
|
|
200
|
+
const observer = new ResizeObserver(() => {
|
|
201
|
+
measure();
|
|
202
|
+
});
|
|
203
|
+
observer.observe(node);
|
|
204
|
+
return () => {
|
|
205
|
+
observer.disconnect();
|
|
206
|
+
};
|
|
207
|
+
}, [rememberNarrowPagerSize, isNarrowLayout, isDetailActive]);
|
|
208
|
+
|
|
112
209
|
if (!children && !renderContent) {
|
|
113
210
|
console.warn("A child node is required");
|
|
114
211
|
return null;
|
|
@@ -205,25 +302,19 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
205
302
|
width={activeTabs.length > 1 ? "100%" : "60%"}
|
|
206
303
|
>
|
|
207
304
|
{activeTabs.map((tabIndex, i) => {
|
|
208
|
-
return (
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
width: "60%",
|
|
222
|
-
}}
|
|
223
|
-
>
|
|
224
|
-
{elementArray[tabIndex]}
|
|
225
|
-
</ScrollView>
|
|
226
|
-
);
|
|
305
|
+
return renderDesktopChildColumn({
|
|
306
|
+
borderRadius: childColumnBorderRadius,
|
|
307
|
+
columnKey: tabIndex,
|
|
308
|
+
element: elementArray[tabIndex],
|
|
309
|
+
paneStyle: {
|
|
310
|
+
flex: 1,
|
|
311
|
+
paddingLeft: i ? 16 : 0,
|
|
312
|
+
paddingRight: i ? 0 : 16,
|
|
313
|
+
width: "60%",
|
|
314
|
+
},
|
|
315
|
+
scrollTestID: `split-page-desktop-child-scroll-${i}`,
|
|
316
|
+
testID: `split-page-desktop-segment-child-${i}`,
|
|
317
|
+
});
|
|
227
318
|
})}
|
|
228
319
|
</Box>
|
|
229
320
|
</View>
|
|
@@ -258,24 +349,19 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
258
349
|
testID="split-page-desktop-children-scroll"
|
|
259
350
|
>
|
|
260
351
|
{elementArray.map((element, index) => {
|
|
261
|
-
return (
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
testID={`split-page-desktop-child-${index}`}
|
|
275
|
-
>
|
|
276
|
-
{element}
|
|
277
|
-
</ScrollView>
|
|
278
|
-
);
|
|
352
|
+
return renderDesktopChildColumn({
|
|
353
|
+
borderRadius: childColumnBorderRadius,
|
|
354
|
+
columnKey: index,
|
|
355
|
+
element,
|
|
356
|
+
paneStyle: {
|
|
357
|
+
flexGrow: 0,
|
|
358
|
+
flexShrink: 0,
|
|
359
|
+
maxWidth: childWidth,
|
|
360
|
+
width: childWidth,
|
|
361
|
+
},
|
|
362
|
+
scrollTestID: `split-page-desktop-child-scroll-${index}`,
|
|
363
|
+
testID: `split-page-desktop-child-${index}`,
|
|
364
|
+
});
|
|
279
365
|
})}
|
|
280
366
|
</ScrollView>
|
|
281
367
|
);
|
|
@@ -284,23 +370,17 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
284
370
|
return (
|
|
285
371
|
<Box alignItems="center" direction="row" flex="grow" justifyContent="center" paddingX={2}>
|
|
286
372
|
{elementArray.map((element, index) => {
|
|
287
|
-
return (
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
width: "60%",
|
|
299
|
-
}}
|
|
300
|
-
>
|
|
301
|
-
{element}
|
|
302
|
-
</ScrollView>
|
|
303
|
-
);
|
|
373
|
+
return renderDesktopChildColumn({
|
|
374
|
+
borderRadius: childColumnBorderRadius,
|
|
375
|
+
columnKey: index,
|
|
376
|
+
element,
|
|
377
|
+
paneStyle: {
|
|
378
|
+
flex: 1,
|
|
379
|
+
width: "60%",
|
|
380
|
+
},
|
|
381
|
+
scrollTestID: `split-page-desktop-child-scroll-${index}`,
|
|
382
|
+
testID: `split-page-desktop-row-child-${index}`,
|
|
383
|
+
});
|
|
304
384
|
})}
|
|
305
385
|
</Box>
|
|
306
386
|
);
|
|
@@ -362,19 +442,47 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
362
442
|
swiperRef.current?.scrollToIndex({animated: true, index: destination});
|
|
363
443
|
};
|
|
364
444
|
|
|
445
|
+
// The horizontal pager's content container sizes to its children, so height: "100%" on a page
|
|
446
|
+
// grows with the child instead of the visible pane. overflowY: hidden on that pager then clips
|
|
447
|
+
// the extra height. A measured pixel height gives the page a definite box: rounded corners still
|
|
448
|
+
// clip, and a height: "100%" child can scroll inside that box.
|
|
449
|
+
const narrowPageHeight = (ratio: number): number | "100%" | "90%" => {
|
|
450
|
+
if (measuredPageHeight > 0) {
|
|
451
|
+
return measuredPageHeight * ratio;
|
|
452
|
+
}
|
|
453
|
+
return ratio === 1 ? "100%" : "90%";
|
|
454
|
+
};
|
|
455
|
+
|
|
365
456
|
const renderLabeledMobilePager = (labels: string[]) => {
|
|
366
457
|
const pageWidth = measuredPageWidth > 0 ? measuredPageWidth : windowWidth;
|
|
367
458
|
const lastIndex = elementArray.length - 1;
|
|
368
|
-
const
|
|
459
|
+
const navInset = bottomNavBarHeight ?? 0;
|
|
460
|
+
const labeledChromeHeight =
|
|
461
|
+
labeledPagerEdgeSpacing +
|
|
462
|
+
labeledPagerEdgeSpacing +
|
|
463
|
+
labeledColumnNavButtonHeight +
|
|
464
|
+
labeledPagerEdgeSpacing +
|
|
465
|
+
navInset;
|
|
466
|
+
const columnHeight =
|
|
467
|
+
measuredPageHeight > 0 ? Math.max(measuredPageHeight - labeledChromeHeight, 0) : undefined;
|
|
468
|
+
const navSlotStyle: ViewStyle = {
|
|
469
|
+
alignItems: "center",
|
|
470
|
+
flexShrink: 0,
|
|
471
|
+
height: labeledColumnNavButtonHeight,
|
|
472
|
+
justifyContent: "center",
|
|
473
|
+
width: labeledColumnNavButtonHeight,
|
|
474
|
+
};
|
|
369
475
|
return (
|
|
370
476
|
<View
|
|
371
|
-
onLayout={
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}}
|
|
375
|
-
style={{flex: 1, width: "100%"}}
|
|
477
|
+
onLayout={onNarrowPagerLayout}
|
|
478
|
+
ref={narrowPagerRef}
|
|
479
|
+
style={{flex: 1, height: "100%", minHeight: 0, width: "100%"}}
|
|
376
480
|
testID="split-page-mobile-children"
|
|
377
481
|
>
|
|
482
|
+
<View
|
|
483
|
+
style={{flexShrink: 0, height: labeledPagerEdgeSpacing}}
|
|
484
|
+
testID="split-page-column-top-space"
|
|
485
|
+
/>
|
|
378
486
|
<SwiperFlatList
|
|
379
487
|
getItemLayout={(_data, index) => ({
|
|
380
488
|
index,
|
|
@@ -387,7 +495,13 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
387
495
|
}}
|
|
388
496
|
ref={swiperRef}
|
|
389
497
|
renderAll
|
|
390
|
-
style={{
|
|
498
|
+
style={{
|
|
499
|
+
flexGrow: columnHeight === undefined ? 1 : 0,
|
|
500
|
+
flexShrink: 1,
|
|
501
|
+
height: columnHeight,
|
|
502
|
+
minHeight: 0,
|
|
503
|
+
width: "100%",
|
|
504
|
+
}}
|
|
391
505
|
>
|
|
392
506
|
{elementArray.map((element, index) => {
|
|
393
507
|
return (
|
|
@@ -395,10 +509,9 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
395
509
|
key={index}
|
|
396
510
|
style={{
|
|
397
511
|
borderRadius: childColumnBorderRadius,
|
|
398
|
-
height: "100%",
|
|
512
|
+
height: columnHeight ?? "100%",
|
|
399
513
|
overflow: "hidden",
|
|
400
514
|
padding: 0,
|
|
401
|
-
paddingBottom: bottomNavBarHeight,
|
|
402
515
|
width: pageWidth,
|
|
403
516
|
}}
|
|
404
517
|
testID={`split-page-mobile-child-${index}`}
|
|
@@ -408,55 +521,67 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
408
521
|
);
|
|
409
522
|
})}
|
|
410
523
|
</SwiperFlatList>
|
|
411
|
-
{narrowViewportListButtonLabel ? (
|
|
412
|
-
<View
|
|
413
|
-
style={{
|
|
414
|
-
bottom: controlBottom,
|
|
415
|
-
left: 16,
|
|
416
|
-
position: "absolute",
|
|
417
|
-
zIndex: 1,
|
|
418
|
-
}}
|
|
419
|
-
>
|
|
420
|
-
<IconButton
|
|
421
|
-
accessibilityHint={narrowViewportListButtonLabel}
|
|
422
|
-
accessibilityLabel={narrowViewportListButtonLabel}
|
|
423
|
-
iconName="arrow-left"
|
|
424
|
-
onClick={() => onItemDeselect()}
|
|
425
|
-
testID="split-page-back-to-list"
|
|
426
|
-
/>
|
|
427
|
-
</View>
|
|
428
|
-
) : null}
|
|
429
524
|
<View
|
|
430
525
|
style={{
|
|
431
|
-
|
|
526
|
+
alignItems: "center",
|
|
432
527
|
flexDirection: "row",
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
528
|
+
flexShrink: 0,
|
|
529
|
+
height: labeledColumnNavButtonHeight,
|
|
530
|
+
justifyContent: "space-between",
|
|
531
|
+
marginTop: labeledPagerEdgeSpacing,
|
|
532
|
+
paddingHorizontal: getSpacing(4),
|
|
437
533
|
}}
|
|
534
|
+
testID="split-page-column-nav"
|
|
438
535
|
>
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
536
|
+
<View
|
|
537
|
+
style={{
|
|
538
|
+
alignItems: "center",
|
|
539
|
+
flexDirection: "row",
|
|
540
|
+
flexShrink: 0,
|
|
541
|
+
gap: labeledPagerEdgeSpacing,
|
|
542
|
+
}}
|
|
543
|
+
>
|
|
544
|
+
{narrowViewportListButtonLabel ? (
|
|
545
|
+
<View style={navSlotStyle} testID="split-page-column-back-slot">
|
|
546
|
+
<IconButton
|
|
547
|
+
accessibilityHint={narrowViewportListButtonLabel}
|
|
548
|
+
accessibilityLabel={narrowViewportListButtonLabel}
|
|
549
|
+
iconName="arrow-left"
|
|
550
|
+
onClick={() => onItemDeselect()}
|
|
551
|
+
testID="split-page-back-to-list"
|
|
552
|
+
/>
|
|
553
|
+
</View>
|
|
554
|
+
) : null}
|
|
555
|
+
<View accessible={false} style={navSlotStyle} testID="split-page-column-previous-slot">
|
|
556
|
+
{activeChildIndex > 0 ? (
|
|
557
|
+
<IconButton
|
|
558
|
+
accessibilityLabel={`Show previous column: ${labels[activeChildIndex - 1]}`}
|
|
559
|
+
iconName="chevron-left"
|
|
560
|
+
onClick={() => {
|
|
561
|
+
showMobileChild(activeChildIndex - 1);
|
|
562
|
+
}}
|
|
563
|
+
testID="split-page-column-previous"
|
|
564
|
+
/>
|
|
565
|
+
) : null}
|
|
566
|
+
</View>
|
|
567
|
+
</View>
|
|
568
|
+
<View accessible={false} style={navSlotStyle} testID="split-page-column-next-slot">
|
|
569
|
+
{activeChildIndex < lastIndex ? (
|
|
570
|
+
<IconButton
|
|
571
|
+
accessibilityLabel={`Show next column: ${labels[activeChildIndex + 1]}`}
|
|
572
|
+
iconName="chevron-right"
|
|
573
|
+
onClick={() => {
|
|
574
|
+
showMobileChild(activeChildIndex + 1);
|
|
575
|
+
}}
|
|
576
|
+
testID="split-page-column-next"
|
|
577
|
+
/>
|
|
578
|
+
) : null}
|
|
579
|
+
</View>
|
|
459
580
|
</View>
|
|
581
|
+
<View
|
|
582
|
+
style={{flexShrink: 0, height: labeledPagerEdgeSpacing + navInset}}
|
|
583
|
+
testID="split-page-column-bottom-space"
|
|
584
|
+
/>
|
|
460
585
|
</View>
|
|
461
586
|
);
|
|
462
587
|
};
|
|
@@ -473,32 +598,41 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
473
598
|
) {
|
|
474
599
|
return renderLabeledMobilePager(narrowViewportChildLabels);
|
|
475
600
|
}
|
|
601
|
+
const pageRatio = elementArray.length > 1 ? 0.9 : 1;
|
|
476
602
|
return (
|
|
477
|
-
<
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
style={{width: "100%"}}
|
|
603
|
+
<View
|
|
604
|
+
onLayout={onNarrowPagerLayout}
|
|
605
|
+
ref={narrowPagerRef}
|
|
606
|
+
style={{flex: 1, height: "100%", minHeight: 0, width: "100%"}}
|
|
607
|
+
testID="split-page-dotted-pager"
|
|
483
608
|
>
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
609
|
+
<SwiperFlatList
|
|
610
|
+
nestedScrollEnabled
|
|
611
|
+
paginationStyle={{justifyContent: "center", width: "95%"}}
|
|
612
|
+
renderAll
|
|
613
|
+
showPagination
|
|
614
|
+
style={{height: "100%", width: "100%"}}
|
|
615
|
+
>
|
|
616
|
+
{elementArray.map((element, i) => {
|
|
617
|
+
return (
|
|
618
|
+
<View
|
|
619
|
+
key={i}
|
|
620
|
+
style={{
|
|
621
|
+
borderRadius: childColumnBorderRadius,
|
|
622
|
+
height: narrowPageHeight(pageRatio),
|
|
623
|
+
overflow: "hidden",
|
|
624
|
+
padding: 4,
|
|
625
|
+
paddingBottom: bottomNavBarHeight,
|
|
626
|
+
width: windowWidth - 8,
|
|
627
|
+
}}
|
|
628
|
+
testID={`split-page-dotted-child-${i}`}
|
|
629
|
+
>
|
|
630
|
+
{element}
|
|
631
|
+
</View>
|
|
632
|
+
);
|
|
633
|
+
})}
|
|
634
|
+
</SwiperFlatList>
|
|
635
|
+
</View>
|
|
502
636
|
);
|
|
503
637
|
};
|
|
504
638
|
|
|
@@ -529,7 +663,7 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
529
663
|
return (
|
|
530
664
|
<Box
|
|
531
665
|
avoidKeyboard
|
|
532
|
-
color={color || "
|
|
666
|
+
color={color || "baseAlternate"}
|
|
533
667
|
direction="row"
|
|
534
668
|
display="flex"
|
|
535
669
|
height="100%"
|
package/src/TerrenoProvider.tsx
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
2
|
import type {FC} from "react";
|
|
3
3
|
|
|
4
|
-
import type {IconRegistryMap} from "./Common";
|
|
4
|
+
import type {IconRegistryMap, ThemePrimitives} from "./Common";
|
|
5
5
|
import {IconRegistryProvider} from "./IconRegistry";
|
|
6
6
|
import {OpenAPIProvider} from "./OpenAPIContext";
|
|
7
7
|
import {Host} from "./PortalHost";
|
|
8
|
-
import {ThemeProvider} from "./Theme";
|
|
8
|
+
import {type DeepPartial, type ThemeColorScheme, ThemeProvider} from "./Theme";
|
|
9
9
|
import {Toast} from "./Toast";
|
|
10
10
|
import {ToastProvider} from "./ToastNotifications";
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export interface TerrenoProviderProps {
|
|
13
13
|
children: React.ReactNode;
|
|
14
|
+
colorScheme?: ThemeColorScheme;
|
|
15
|
+
initialPrimitives?: DeepPartial<ThemePrimitives>;
|
|
14
16
|
openAPISpecUrl?: string;
|
|
15
17
|
/**
|
|
16
18
|
* Custom icons to register, keyed by icon name. Registered names take
|
|
@@ -18,9 +20,17 @@ export const TerrenoProvider: FC<{
|
|
|
18
20
|
* is accepted (Icon, Button, IconButton, fields, etc.).
|
|
19
21
|
*/
|
|
20
22
|
icons?: IconRegistryMap;
|
|
21
|
-
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const TerrenoProvider: FC<TerrenoProviderProps> = ({
|
|
26
|
+
children,
|
|
27
|
+
colorScheme,
|
|
28
|
+
initialPrimitives,
|
|
29
|
+
openAPISpecUrl,
|
|
30
|
+
icons,
|
|
31
|
+
}) => {
|
|
22
32
|
return (
|
|
23
|
-
<ThemeProvider>
|
|
33
|
+
<ThemeProvider colorScheme={colorScheme} initialPrimitives={initialPrimitives}>
|
|
24
34
|
<IconRegistryProvider icons={icons}>
|
|
25
35
|
<ToastProvider
|
|
26
36
|
animationDuration={250}
|