@terreno/ui 57.7.0 → 57.9.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/AreaChart.d.ts +1 -1
- package/dist/AreaChart.d.ts.map +1 -1
- package/dist/AreaChart.js +70 -22
- package/dist/AreaChart.js.map +1 -1
- package/dist/Avatar.js +2 -2
- package/dist/Avatar.js.map +1 -1
- package/dist/BarChart.d.ts.map +1 -1
- package/dist/BarChart.js +55 -13
- package/dist/BarChart.js.map +1 -1
- package/dist/Button.js +2 -2
- package/dist/Button.js.map +1 -1
- package/dist/ChartCard.d.ts +5 -0
- package/dist/ChartCard.d.ts.map +1 -0
- package/dist/ChartCard.js +18 -0
- package/dist/ChartCard.js.map +1 -0
- package/dist/Common.d.ts +128 -5
- package/dist/Common.d.ts.map +1 -1
- package/dist/Common.js.map +1 -1
- package/dist/DashboardGrid.d.ts +6 -2
- package/dist/DashboardGrid.d.ts.map +1 -1
- package/dist/DashboardGrid.js +43 -10
- package/dist/DashboardGrid.js.map +1 -1
- package/dist/DateTimeActionSheet.js +2 -2
- package/dist/DateTimeActionSheet.js.map +1 -1
- package/dist/DateTimeField.js +3 -3
- package/dist/DateTimeField.js.map +1 -1
- package/dist/DonutChart.d.ts.map +1 -1
- package/dist/DonutChart.js +20 -10
- package/dist/DonutChart.js.map +1 -1
- package/dist/DropdownMenuItem.d.ts +16 -0
- package/dist/DropdownMenuItem.d.ts.map +1 -0
- package/dist/DropdownMenuItem.js +11 -0
- package/dist/DropdownMenuItem.js.map +1 -0
- package/dist/DropdownPanel.d.ts.map +1 -1
- package/dist/DropdownPanel.js +1 -1
- package/dist/DropdownPanel.js.map +1 -1
- package/dist/FilePickerButton.d.ts.map +1 -1
- package/dist/FilePickerButton.js +70 -10
- package/dist/FilePickerButton.js.map +1 -1
- package/dist/GPTChat.d.ts.map +1 -1
- package/dist/GPTChat.js +103 -14
- package/dist/GPTChat.js.map +1 -1
- package/dist/HeightField.js +2 -2
- package/dist/HeightField.js.map +1 -1
- package/dist/IconButton.d.ts.map +1 -1
- package/dist/IconButton.js +9 -6
- package/dist/IconButton.js.map +1 -1
- package/dist/LineChart.d.ts +1 -1
- package/dist/LineChart.d.ts.map +1 -1
- package/dist/LineChart.js +62 -21
- package/dist/LineChart.js.map +1 -1
- package/dist/MediaQuery.d.ts +10 -0
- package/dist/MediaQuery.d.ts.map +1 -1
- package/dist/MediaQuery.js +13 -1
- package/dist/MediaQuery.js.map +1 -1
- package/dist/MultiselectField.js +2 -2
- package/dist/MultiselectField.js.map +1 -1
- package/dist/RadioField.js +2 -2
- package/dist/RadioField.js.map +1 -1
- package/dist/Scorecard.d.ts +5 -0
- package/dist/Scorecard.d.ts.map +1 -0
- package/dist/Scorecard.js +11 -0
- package/dist/Scorecard.js.map +1 -0
- package/dist/SparklineChart.d.ts +5 -0
- package/dist/SparklineChart.d.ts.map +1 -0
- package/dist/SparklineChart.js +35 -0
- package/dist/SparklineChart.js.map +1 -0
- package/dist/SplitPage.d.ts +1 -1
- package/dist/SplitPage.d.ts.map +1 -1
- package/dist/SplitPage.js +126 -21
- package/dist/SplitPage.js.map +1 -1
- package/dist/TextField.d.ts.map +1 -1
- package/dist/TextField.js +12 -4
- package/dist/TextField.js.map +1 -1
- package/dist/ToastNotifications.d.ts.map +1 -1
- package/dist/ToastNotifications.js +29 -6
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/UnifiedAddressAutoComplete.js +2 -2
- package/dist/UnifiedAddressAutoComplete.js.map +1 -1
- package/dist/WebDropdownMenu.d.ts +2 -1
- package/dist/WebDropdownMenu.d.ts.map +1 -1
- package/dist/WebDropdownMenu.js +2 -6
- package/dist/WebDropdownMenu.js.map +1 -1
- package/dist/charts/ChartFacadeContainer.d.ts +10 -0
- package/dist/charts/ChartFacadeContainer.d.ts.map +1 -0
- package/dist/charts/ChartFacadeContainer.js +10 -0
- package/dist/charts/ChartFacadeContainer.js.map +1 -0
- package/dist/charts/ChartFrame.d.ts +4 -0
- package/dist/charts/ChartFrame.d.ts.map +1 -1
- package/dist/charts/ChartFrame.js +4 -2
- package/dist/charts/ChartFrame.js.map +1 -1
- package/dist/charts/layout.d.ts +9 -2
- package/dist/charts/layout.d.ts.map +1 -1
- package/dist/charts/layout.js +28 -6
- package/dist/charts/layout.js.map +1 -1
- package/dist/charts/scales.d.ts +3 -1
- package/dist/charts/scales.d.ts.map +1 -1
- package/dist/charts/scales.js +7 -7
- package/dist/charts/scales.js.map +1 -1
- package/dist/charts/series.d.ts +15 -0
- package/dist/charts/series.d.ts.map +1 -0
- package/dist/charts/series.js +19 -0
- package/dist/charts/series.js.map +1 -0
- package/dist/charts/types/chartTypes.d.ts +7 -0
- package/dist/charts/types/chartTypes.d.ts.map +1 -1
- package/dist/dashboardGridLayout.d.ts +6 -0
- package/dist/dashboardGridLayout.d.ts.map +1 -1
- package/dist/dashboardGridLayout.js +19 -3
- package/dist/dashboardGridLayout.js.map +1 -1
- package/dist/fieldElements/FieldTitle.js +2 -2
- package/dist/fieldElements/FieldTitle.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts +9 -0
- package/dist/lazyBoundaries/heavyOptionalExports.d.ts.map +1 -1
- package/dist/lazyBoundaries/heavyOptionalExports.js +6 -0
- package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -1
- package/dist/resolveDocumentBodyPortalTarget.d.ts +7 -0
- package/dist/resolveDocumentBodyPortalTarget.d.ts.map +1 -0
- package/dist/resolveDocumentBodyPortalTarget.js +12 -0
- package/dist/resolveDocumentBodyPortalTarget.js.map +1 -0
- package/package.json +1 -1
- package/src/AIRequestExplorer.test.tsx +2 -2
- package/src/AreaChart.test.tsx +81 -0
- package/src/AreaChart.tsx +171 -62
- package/src/Avatar.tsx +2 -2
- package/src/BarChart.test.tsx +119 -0
- package/src/BarChart.tsx +94 -20
- package/src/Button.test.tsx +7 -7
- package/src/Button.tsx +2 -2
- package/src/ChartCard.test.tsx +79 -0
- package/src/ChartCard.tsx +80 -0
- package/src/Common.ts +119 -2
- package/src/DashboardGrid.test.tsx +98 -1
- package/src/DashboardGrid.tsx +71 -20
- package/src/DateTimeActionSheet.tsx +4 -4
- package/src/DateTimeField.test.tsx +5 -4
- package/src/DateTimeField.tsx +3 -3
- package/src/DonutChart.test.tsx +73 -0
- package/src/DonutChart.tsx +87 -14
- package/src/DropdownMenuItem.tsx +48 -0
- package/src/DropdownPanel.test.tsx +12 -0
- package/src/DropdownPanel.tsx +8 -1
- package/src/FilePickerButton.test.tsx +60 -6
- package/src/FilePickerButton.tsx +116 -28
- package/src/GPTChat.test.tsx +133 -6
- package/src/GPTChat.tsx +196 -38
- package/src/HeightField.tsx +2 -2
- package/src/IconButton.test.tsx +63 -0
- package/src/IconButton.tsx +10 -5
- package/src/LineChart.test.tsx +104 -0
- package/src/LineChart.tsx +154 -58
- package/src/MediaQuery.ts +14 -1
- package/src/MultiselectField.tsx +2 -2
- package/src/RadioField.tsx +2 -2
- package/src/Scorecard.test.tsx +65 -0
- package/src/Scorecard.tsx +45 -0
- package/src/SparklineChart.test.tsx +69 -0
- package/src/SparklineChart.tsx +85 -0
- package/src/SplitPage.test.tsx +449 -11
- package/src/SplitPage.tsx +255 -21
- package/src/TextField.test.tsx +16 -0
- package/src/TextField.tsx +13 -3
- package/src/ToastNotifications.tsx +33 -6
- package/src/ToastNotifications.webModal.test.tsx +285 -0
- package/src/UnifiedAddressAutoComplete.test.tsx +4 -4
- package/src/UnifiedAddressAutoComplete.tsx +2 -2
- package/src/WebDropdownMenu.tsx +3 -7
- package/src/__snapshots__/DropdownPanel.test.tsx.snap +3 -1
- package/src/bunSetup.ts +3 -1
- package/src/charts/ChartFacadeContainer.tsx +35 -0
- package/src/charts/ChartFrame.tsx +39 -1
- package/src/charts/layout.test.ts +22 -1
- package/src/charts/layout.ts +37 -4
- package/src/charts/scales.test.ts +33 -0
- package/src/charts/scales.ts +10 -6
- package/src/charts/series.ts +43 -0
- package/src/charts/types/chartTypes.ts +8 -0
- package/src/dashboardGridLayout.test.ts +59 -1
- package/src/dashboardGridLayout.ts +30 -3
- package/src/fieldElements/FieldTitle.tsx +2 -2
- package/src/index.tsx +6 -0
- package/src/lazyBoundaries/heavyOptionalExports.tsx +21 -0
- package/src/resolveDocumentBodyPortalTarget.ts +11 -0
package/src/SplitPage.tsx
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
type ComponentProps,
|
|
4
|
+
type ElementRef,
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from "react";
|
|
10
|
+
import {
|
|
11
|
+
type LayoutChangeEvent,
|
|
12
|
+
type ListRenderItemInfo,
|
|
13
|
+
ScrollView,
|
|
14
|
+
useWindowDimensions,
|
|
15
|
+
View,
|
|
16
|
+
} from "react-native";
|
|
3
17
|
import {SwiperFlatList} from "react-native-swiper-flatlist";
|
|
4
18
|
|
|
5
19
|
import {Box} from "./Box";
|
|
6
20
|
import type {SplitPageListItem, SplitPageProps} from "./Common";
|
|
7
21
|
import {FlatList} from "./FlatList";
|
|
8
22
|
import {IconButton} from "./IconButton";
|
|
9
|
-
import {
|
|
23
|
+
import {isNarrowViewport} from "./MediaQuery";
|
|
10
24
|
import {SegmentedControl} from "./SegmentedControl";
|
|
11
25
|
import {Spinner} from "./Spinner";
|
|
12
26
|
import {useTheme} from "./Theme";
|
|
13
27
|
|
|
14
28
|
// A component for rendering a list on one side and a details view on the right for large screens,
|
|
15
29
|
// and a scrollable list where clicking an item takes you the details view.
|
|
30
|
+
// On web, opt in to minimum widths for the desktop side-by-side children, or a labeled pager
|
|
31
|
+
// on the narrow viewport. `narrowBelowWidth` chooses that viewport from the window width;
|
|
32
|
+
// otherwise it follows `isNarrowViewport()`. The native SplitPage ignores those props.
|
|
16
33
|
export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
17
34
|
children,
|
|
18
35
|
tabs = [],
|
|
@@ -28,14 +45,28 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
28
45
|
listViewWidth,
|
|
29
46
|
listViewMaxWidth,
|
|
30
47
|
bottomNavBarHeight,
|
|
48
|
+
desktopChildrenMinWidth,
|
|
49
|
+
narrowBelowWidth,
|
|
50
|
+
narrowViewportChildLabels,
|
|
51
|
+
narrowViewportListButtonLabel,
|
|
52
|
+
narrowViewportSelectionActive,
|
|
53
|
+
narrowViewportSelectionKey,
|
|
31
54
|
showItemList,
|
|
32
55
|
}: SplitPageProps<TItem>) => {
|
|
33
56
|
const {theme} = useTheme();
|
|
57
|
+
const {width: windowWidth} = useWindowDimensions();
|
|
34
58
|
const [selectedId, setSelectedId] = useState<number | undefined>(undefined);
|
|
35
59
|
const [activeTabs, setActiveTabs] = useState<number[]>([0, 1]);
|
|
36
|
-
const
|
|
60
|
+
const [activeChildIndex, setActiveChildIndex] = useState(0);
|
|
61
|
+
const activeChildIndexRef = useRef(activeChildIndex);
|
|
62
|
+
activeChildIndexRef.current = activeChildIndex;
|
|
63
|
+
const swiperRef = useRef<ElementRef<typeof SwiperFlatList> | null>(null);
|
|
64
|
+
const [desktopScrollWidth, setDesktopScrollWidth] = useState(0);
|
|
65
|
+
const [measuredPageWidth, setMeasuredPageWidth] = useState(0);
|
|
37
66
|
|
|
38
|
-
const
|
|
67
|
+
const isNarrowLayout =
|
|
68
|
+
narrowBelowWidth === undefined ? isNarrowViewport() : windowWidth <= narrowBelowWidth;
|
|
69
|
+
const isDetailActive = selectedId !== undefined || narrowViewportSelectionActive === true;
|
|
39
70
|
|
|
40
71
|
const elementArray = Children.toArray(children).filter((c) => c !== null);
|
|
41
72
|
|
|
@@ -59,6 +90,23 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
59
90
|
}
|
|
60
91
|
}, [showItemList, onItemDeselect]);
|
|
61
92
|
|
|
93
|
+
// Reset the narrow pager when the selected record changes. Width changes stay out of this effect
|
|
94
|
+
// so a resize does not jump back to the first child.
|
|
95
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: these values are the reset triggers.
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
setActiveChildIndex(0);
|
|
98
|
+
swiperRef.current?.scrollToIndex({animated: false, index: 0});
|
|
99
|
+
}, [isDetailActive, isNarrowLayout, narrowViewportSelectionKey, selectedId]);
|
|
100
|
+
|
|
101
|
+
// Keep the current child aligned after the page width changes, without snapping over a chevron animation.
|
|
102
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: widths are the realign triggers; the index is read from a ref.
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
swiperRef.current?.scrollToIndex({
|
|
105
|
+
animated: false,
|
|
106
|
+
index: activeChildIndexRef.current,
|
|
107
|
+
});
|
|
108
|
+
}, [measuredPageWidth, windowWidth]);
|
|
109
|
+
|
|
62
110
|
if (!children && !renderContent) {
|
|
63
111
|
console.warn("A child node is required");
|
|
64
112
|
return null;
|
|
@@ -69,6 +117,19 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
69
117
|
return null;
|
|
70
118
|
}
|
|
71
119
|
|
|
120
|
+
if (desktopChildrenMinWidth !== undefined && elementArray.length > 2) {
|
|
121
|
+
console.warn("desktopChildrenMinWidth applies only when SplitPage has two or fewer children.");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (
|
|
125
|
+
narrowViewportChildLabels !== undefined &&
|
|
126
|
+
narrowViewportChildLabels.length !== elementArray.length
|
|
127
|
+
) {
|
|
128
|
+
console.warn(
|
|
129
|
+
"narrowViewportChildLabels must have one entry per child. Falling back to the default narrow pager."
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
72
133
|
const renderItem = (itemInfo: ListRenderItemInfo<TItem>) => {
|
|
73
134
|
return (
|
|
74
135
|
<Box
|
|
@@ -163,33 +224,82 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
163
224
|
</Box>
|
|
164
225
|
</View>
|
|
165
226
|
);
|
|
166
|
-
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (
|
|
230
|
+
desktopChildrenMinWidth !== undefined &&
|
|
231
|
+
elementArray.length >= 1 &&
|
|
232
|
+
elementArray.length <= 2
|
|
233
|
+
) {
|
|
234
|
+
const childCount = elementArray.length;
|
|
235
|
+
const childWidth =
|
|
236
|
+
desktopScrollWidth > 0
|
|
237
|
+
? Math.max(desktopChildrenMinWidth, desktopScrollWidth / childCount)
|
|
238
|
+
: desktopChildrenMinWidth;
|
|
239
|
+
const rowWidth = Math.max(
|
|
240
|
+
desktopScrollWidth,
|
|
241
|
+
desktopChildrenMinWidth * childCount,
|
|
242
|
+
childWidth * childCount
|
|
243
|
+
);
|
|
167
244
|
return (
|
|
168
|
-
<
|
|
245
|
+
<ScrollView
|
|
246
|
+
contentContainerStyle={{flexDirection: "row", width: rowWidth}}
|
|
247
|
+
horizontal
|
|
248
|
+
nestedScrollEnabled
|
|
249
|
+
onLayout={(event: LayoutChangeEvent) => {
|
|
250
|
+
const nextWidth = event.nativeEvent.layout.width;
|
|
251
|
+
setDesktopScrollWidth((current) => (current === nextWidth ? current : nextWidth));
|
|
252
|
+
}}
|
|
253
|
+
style={{flex: 1, height: "100%"}}
|
|
254
|
+
testID="split-page-desktop-children-scroll"
|
|
255
|
+
>
|
|
169
256
|
{elementArray.map((element, index) => {
|
|
170
257
|
return (
|
|
171
258
|
<ScrollView
|
|
172
|
-
contentContainerStyle={{
|
|
173
|
-
flex: 1,
|
|
174
|
-
}}
|
|
259
|
+
contentContainerStyle={{flexGrow: 1}}
|
|
175
260
|
key={index}
|
|
176
261
|
style={{
|
|
177
|
-
|
|
262
|
+
flexGrow: 0,
|
|
263
|
+
flexShrink: 0,
|
|
178
264
|
height: "100%",
|
|
179
|
-
|
|
265
|
+
maxWidth: childWidth,
|
|
266
|
+
width: childWidth,
|
|
180
267
|
}}
|
|
268
|
+
testID={`split-page-desktop-child-${index}`}
|
|
181
269
|
>
|
|
182
270
|
{element}
|
|
183
271
|
</ScrollView>
|
|
184
272
|
);
|
|
185
273
|
})}
|
|
186
|
-
</
|
|
274
|
+
</ScrollView>
|
|
187
275
|
);
|
|
188
276
|
}
|
|
277
|
+
|
|
278
|
+
return (
|
|
279
|
+
<Box alignItems="center" direction="row" flex="grow" justifyContent="center" paddingX={2}>
|
|
280
|
+
{elementArray.map((element, index) => {
|
|
281
|
+
return (
|
|
282
|
+
<ScrollView
|
|
283
|
+
contentContainerStyle={{
|
|
284
|
+
flex: 1,
|
|
285
|
+
}}
|
|
286
|
+
key={index}
|
|
287
|
+
style={{
|
|
288
|
+
flex: 1,
|
|
289
|
+
height: "100%",
|
|
290
|
+
width: "60%",
|
|
291
|
+
}}
|
|
292
|
+
>
|
|
293
|
+
{element}
|
|
294
|
+
</ScrollView>
|
|
295
|
+
);
|
|
296
|
+
})}
|
|
297
|
+
</Box>
|
|
298
|
+
);
|
|
189
299
|
};
|
|
190
300
|
|
|
191
301
|
const renderMobileList = () => {
|
|
192
|
-
if (
|
|
302
|
+
if (isNarrowLayout && isDetailActive) {
|
|
193
303
|
return null;
|
|
194
304
|
}
|
|
195
305
|
|
|
@@ -218,13 +328,13 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
218
328
|
};
|
|
219
329
|
|
|
220
330
|
const renderMobileListContent = () => {
|
|
221
|
-
if (
|
|
331
|
+
if (isNarrowLayout && !isDetailActive) {
|
|
222
332
|
return null;
|
|
223
333
|
}
|
|
224
334
|
|
|
225
335
|
return (
|
|
226
336
|
<Box flex="grow" padding={2}>
|
|
227
|
-
{
|
|
337
|
+
{isNarrowLayout && (
|
|
228
338
|
<Box width="100%">
|
|
229
339
|
<IconButton
|
|
230
340
|
accessibilityHint="close split page"
|
|
@@ -239,10 +349,126 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
239
349
|
);
|
|
240
350
|
};
|
|
241
351
|
|
|
352
|
+
const showMobileChild = (destination: number): void => {
|
|
353
|
+
setActiveChildIndex(destination);
|
|
354
|
+
swiperRef.current?.scrollToIndex({animated: true, index: destination});
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
const renderLabeledMobilePager = (labels: string[]) => {
|
|
358
|
+
const pageWidth = measuredPageWidth > 0 ? measuredPageWidth : windowWidth;
|
|
359
|
+
const lastIndex = elementArray.length - 1;
|
|
360
|
+
const controlBottom = (bottomNavBarHeight ?? 0) + 8;
|
|
361
|
+
return (
|
|
362
|
+
<View
|
|
363
|
+
onLayout={(event: LayoutChangeEvent) => {
|
|
364
|
+
const nextWidth = event.nativeEvent.layout.width;
|
|
365
|
+
setMeasuredPageWidth((current) => (current === nextWidth ? current : nextWidth));
|
|
366
|
+
}}
|
|
367
|
+
style={{flex: 1, width: "100%"}}
|
|
368
|
+
testID="split-page-mobile-children"
|
|
369
|
+
>
|
|
370
|
+
<SwiperFlatList
|
|
371
|
+
getItemLayout={(_data, index) => ({
|
|
372
|
+
index,
|
|
373
|
+
length: pageWidth,
|
|
374
|
+
offset: pageWidth * index,
|
|
375
|
+
})}
|
|
376
|
+
nestedScrollEnabled
|
|
377
|
+
onChangeIndex={({index}) => {
|
|
378
|
+
setActiveChildIndex(index);
|
|
379
|
+
}}
|
|
380
|
+
ref={swiperRef}
|
|
381
|
+
renderAll
|
|
382
|
+
style={{width: "100%"}}
|
|
383
|
+
>
|
|
384
|
+
{elementArray.map((element, index) => {
|
|
385
|
+
return (
|
|
386
|
+
<View
|
|
387
|
+
key={index}
|
|
388
|
+
style={{
|
|
389
|
+
height: "100%",
|
|
390
|
+
padding: 0,
|
|
391
|
+
paddingBottom: bottomNavBarHeight,
|
|
392
|
+
width: pageWidth,
|
|
393
|
+
}}
|
|
394
|
+
testID={`split-page-mobile-child-${index}`}
|
|
395
|
+
>
|
|
396
|
+
{element}
|
|
397
|
+
</View>
|
|
398
|
+
);
|
|
399
|
+
})}
|
|
400
|
+
</SwiperFlatList>
|
|
401
|
+
{narrowViewportListButtonLabel ? (
|
|
402
|
+
<View
|
|
403
|
+
style={{
|
|
404
|
+
bottom: controlBottom,
|
|
405
|
+
left: 16,
|
|
406
|
+
position: "absolute",
|
|
407
|
+
zIndex: 1,
|
|
408
|
+
}}
|
|
409
|
+
>
|
|
410
|
+
<IconButton
|
|
411
|
+
accessibilityHint={narrowViewportListButtonLabel}
|
|
412
|
+
accessibilityLabel={narrowViewportListButtonLabel}
|
|
413
|
+
backgroundOpacity={0.88}
|
|
414
|
+
iconName="arrow-left"
|
|
415
|
+
onClick={() => onItemDeselect()}
|
|
416
|
+
testID="split-page-back-to-list"
|
|
417
|
+
variant="muted"
|
|
418
|
+
/>
|
|
419
|
+
</View>
|
|
420
|
+
) : null}
|
|
421
|
+
<View
|
|
422
|
+
style={{
|
|
423
|
+
bottom: controlBottom,
|
|
424
|
+
flexDirection: "row",
|
|
425
|
+
gap: 8,
|
|
426
|
+
position: "absolute",
|
|
427
|
+
right: 16,
|
|
428
|
+
zIndex: 1,
|
|
429
|
+
}}
|
|
430
|
+
>
|
|
431
|
+
{activeChildIndex > 0 ? (
|
|
432
|
+
<IconButton
|
|
433
|
+
accessibilityLabel={`Show previous column: ${labels[activeChildIndex - 1]}`}
|
|
434
|
+
backgroundOpacity={0.88}
|
|
435
|
+
iconName="chevron-left"
|
|
436
|
+
onClick={() => {
|
|
437
|
+
showMobileChild(activeChildIndex - 1);
|
|
438
|
+
}}
|
|
439
|
+
testID="split-page-column-previous"
|
|
440
|
+
variant="muted"
|
|
441
|
+
/>
|
|
442
|
+
) : null}
|
|
443
|
+
{activeChildIndex < lastIndex ? (
|
|
444
|
+
<IconButton
|
|
445
|
+
accessibilityLabel={`Show next column: ${labels[activeChildIndex + 1]}`}
|
|
446
|
+
backgroundOpacity={0.88}
|
|
447
|
+
iconName="chevron-right"
|
|
448
|
+
onClick={() => {
|
|
449
|
+
showMobileChild(activeChildIndex + 1);
|
|
450
|
+
}}
|
|
451
|
+
testID="split-page-column-next"
|
|
452
|
+
variant="muted"
|
|
453
|
+
/>
|
|
454
|
+
) : null}
|
|
455
|
+
</View>
|
|
456
|
+
</View>
|
|
457
|
+
);
|
|
458
|
+
};
|
|
459
|
+
|
|
242
460
|
const renderMobileChildrenContent = () => {
|
|
243
|
-
if (
|
|
461
|
+
if (!isDetailActive) {
|
|
244
462
|
return null;
|
|
245
463
|
}
|
|
464
|
+
if (
|
|
465
|
+
isNarrowLayout &&
|
|
466
|
+
elementArray.length > 1 &&
|
|
467
|
+
narrowViewportChildLabels !== undefined &&
|
|
468
|
+
narrowViewportChildLabels.length === elementArray.length
|
|
469
|
+
) {
|
|
470
|
+
return renderLabeledMobilePager(narrowViewportChildLabels);
|
|
471
|
+
}
|
|
246
472
|
return (
|
|
247
473
|
<SwiperFlatList
|
|
248
474
|
nestedScrollEnabled
|
|
@@ -259,7 +485,7 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
259
485
|
height: elementArray.length > 1 ? "90%" : "100%",
|
|
260
486
|
padding: 4,
|
|
261
487
|
paddingBottom: bottomNavBarHeight,
|
|
262
|
-
width:
|
|
488
|
+
width: windowWidth - 8,
|
|
263
489
|
}}
|
|
264
490
|
>
|
|
265
491
|
{element}
|
|
@@ -283,9 +509,17 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
283
509
|
const renderMainContent = renderContent
|
|
284
510
|
? renderMobileListContent()
|
|
285
511
|
: renderMobileChildrenContent();
|
|
286
|
-
return
|
|
512
|
+
return isDetailActive ? renderMainContent : renderMobileList();
|
|
287
513
|
};
|
|
288
514
|
|
|
515
|
+
const isLabeledPagerBody =
|
|
516
|
+
isNarrowLayout &&
|
|
517
|
+
isDetailActive &&
|
|
518
|
+
!renderContent &&
|
|
519
|
+
elementArray.length > 1 &&
|
|
520
|
+
narrowViewportChildLabels !== undefined &&
|
|
521
|
+
narrowViewportChildLabels.length === elementArray.length;
|
|
522
|
+
|
|
289
523
|
return (
|
|
290
524
|
<Box
|
|
291
525
|
avoidKeyboard
|
|
@@ -294,7 +528,7 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
294
528
|
display="flex"
|
|
295
529
|
height="100%"
|
|
296
530
|
keyboardOffset={keyboardOffset}
|
|
297
|
-
padding={2}
|
|
531
|
+
padding={isLabeledPagerBody ? 0 : 2}
|
|
298
532
|
width="100%"
|
|
299
533
|
>
|
|
300
534
|
{loading === true && (
|
|
@@ -303,7 +537,7 @@ export const SplitPage = <TItem extends SplitPageListItem = SplitPageListItem>({
|
|
|
303
537
|
size="md"
|
|
304
538
|
/>
|
|
305
539
|
)}
|
|
306
|
-
{
|
|
540
|
+
{isNarrowLayout ? renderMobileSplitPage() : renderSplitPage()}
|
|
307
541
|
</Box>
|
|
308
542
|
);
|
|
309
543
|
};
|
package/src/TextField.test.tsx
CHANGED
|
@@ -790,6 +790,22 @@ describe("TextField", () => {
|
|
|
790
790
|
).not.toThrow();
|
|
791
791
|
});
|
|
792
792
|
|
|
793
|
+
it("clears the measured grow height after the controlled value is emptied", async () => {
|
|
794
|
+
const {getByDisplayValue, rerender} = renderWithTheme(
|
|
795
|
+
<TextField grow multiline onChange={mockOnChange} value="long note" />
|
|
796
|
+
);
|
|
797
|
+
fireEvent(getByDisplayValue("long note"), "contentSizeChange", {
|
|
798
|
+
nativeEvent: {contentSize: {height: 120}},
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
rerender(<TextField grow multiline onChange={mockOnChange} value="" />);
|
|
802
|
+
await act(async () => {});
|
|
803
|
+
rerender(<TextField grow multiline onChange={mockOnChange} value="n" />);
|
|
804
|
+
|
|
805
|
+
const styles = [getByDisplayValue("n").props.style].flat(Infinity);
|
|
806
|
+
assert.isTrue(styles.some((style) => style?.height === 40));
|
|
807
|
+
});
|
|
808
|
+
|
|
793
809
|
it("invokes the onFocus callback when the input is focused", () => {
|
|
794
810
|
const {getByDisplayValue} = renderWithTheme(
|
|
795
811
|
<TextField onChange={mockOnChange} onFocus={mockOnFocus} value="" />
|
package/src/TextField.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {getCalendars} from "expo-localization";
|
|
2
|
-
import {type FC, useCallback, useMemo, useRef, useState} from "react";
|
|
2
|
+
import {type FC, useCallback, useEffect, useMemo, useRef, useState} from "react";
|
|
3
3
|
import {
|
|
4
4
|
type DimensionValue,
|
|
5
5
|
type KeyboardTypeOptions,
|
|
@@ -89,6 +89,7 @@ export const TextField: FC<TextFieldProps> = ({
|
|
|
89
89
|
multiline,
|
|
90
90
|
rows = 1,
|
|
91
91
|
grow,
|
|
92
|
+
maxHeight,
|
|
92
93
|
returnKeyType,
|
|
93
94
|
onBlur,
|
|
94
95
|
onFocus,
|
|
@@ -113,6 +114,13 @@ export const TextField: FC<TextFieldProps> = ({
|
|
|
113
114
|
const [isValueRevealed, setIsValueRevealed] = useState(false);
|
|
114
115
|
const textInputRef = useRef<TextInput | null>(null);
|
|
115
116
|
|
|
117
|
+
// Clear stale measured height so the next typed character starts at the default row height.
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (grow && !value) {
|
|
120
|
+
setHeight(rows * 40);
|
|
121
|
+
}
|
|
122
|
+
}, [grow, rows, value]);
|
|
123
|
+
|
|
116
124
|
const isPasswordField = type === "password";
|
|
117
125
|
const hasVisibilityToggle = isPasswordField && showVisibilityToggle;
|
|
118
126
|
|
|
@@ -164,7 +172,9 @@ export const TextField: FC<TextFieldProps> = ({
|
|
|
164
172
|
|
|
165
173
|
const calculatedHeight: DimensionValue = useMemo(() => {
|
|
166
174
|
if (grow) {
|
|
167
|
-
|
|
175
|
+
// React Native Web never reports a smaller content size, so an emptied field resets.
|
|
176
|
+
const grownHeight = value ? Math.max(40, height) : rows * 40;
|
|
177
|
+
return maxHeight ? Math.min(grownHeight, maxHeight) : grownHeight;
|
|
168
178
|
} else if (multiline) {
|
|
169
179
|
return height || "100%";
|
|
170
180
|
} else {
|
|
@@ -172,7 +182,7 @@ export const TextField: FC<TextFieldProps> = ({
|
|
|
172
182
|
// single-line inputs need extra vertical room beyond 16px text.
|
|
173
183
|
return Platform.OS === "ios" ? 24 : 22;
|
|
174
184
|
}
|
|
175
|
-
}, [grow, height, multiline]);
|
|
185
|
+
}, [grow, height, maxHeight, multiline, rows, value]);
|
|
176
186
|
|
|
177
187
|
const defaultTextInputStyles = useMemo(() => {
|
|
178
188
|
const style: StyleProp<TextStyleWithOutline> = {
|
|
@@ -57,6 +57,8 @@ import {
|
|
|
57
57
|
type ViewStyle,
|
|
58
58
|
} from "react-native";
|
|
59
59
|
import type {ToastProps as TerrenoToastPayload} from "./Common";
|
|
60
|
+
import {createWebPortal} from "./createWebPortal";
|
|
61
|
+
import {resolveDocumentBodyPortalTarget} from "./resolveDocumentBodyPortalTarget";
|
|
60
62
|
|
|
61
63
|
// ============================================================================
|
|
62
64
|
// useDimensions hook
|
|
@@ -451,7 +453,16 @@ const toastStyles = StyleSheet.create({
|
|
|
451
453
|
// Toast Container
|
|
452
454
|
// ============================================================================
|
|
453
455
|
|
|
454
|
-
const {height, width} = Dimensions.get("window");
|
|
456
|
+
const {height: windowHeight, width: windowWidth} = Dimensions.get("window");
|
|
457
|
+
|
|
458
|
+
// Static web export renders in Node, where Dimensions reports 0x0 and that size is baked into
|
|
459
|
+
// the HTML. The web container is position:fixed, so percentages track the viewport instead.
|
|
460
|
+
const getContainerSize = (): {height: ViewStyle["height"]; width: ViewStyle["width"]} => {
|
|
461
|
+
if (Platform.OS === "web") {
|
|
462
|
+
return {height: "100%", width: "100%"};
|
|
463
|
+
}
|
|
464
|
+
return {height: windowHeight, width: windowWidth};
|
|
465
|
+
};
|
|
455
466
|
|
|
456
467
|
export interface ToastContainerProps extends ToastOptions {
|
|
457
468
|
renderToast?(toast: ToastProps): ReactElement;
|
|
@@ -634,7 +645,7 @@ const ToastContainer = forwardRef<ToastContainerRef, ToastContainerProps>((props
|
|
|
634
645
|
bottom: offsetBottom || offset,
|
|
635
646
|
flexDirection: "column",
|
|
636
647
|
justifyContent: "flex-end",
|
|
637
|
-
width: width,
|
|
648
|
+
width: getContainerSize().width,
|
|
638
649
|
};
|
|
639
650
|
return (
|
|
640
651
|
<KeyboardAvoidingView
|
|
@@ -657,7 +668,7 @@ const ToastContainer = forwardRef<ToastContainerRef, ToastContainerProps>((props
|
|
|
657
668
|
flexDirection: "column-reverse",
|
|
658
669
|
justifyContent: "flex-start",
|
|
659
670
|
top: offsetTop || offset,
|
|
660
|
-
width: width,
|
|
671
|
+
width: getContainerSize().width,
|
|
661
672
|
};
|
|
662
673
|
return (
|
|
663
674
|
<KeyboardAvoidingView
|
|
@@ -676,12 +687,13 @@ const ToastContainer = forwardRef<ToastContainerRef, ToastContainerProps>((props
|
|
|
676
687
|
}, [toasts, offset, offsetTop]);
|
|
677
688
|
|
|
678
689
|
const renderCenterToasts = useCallback(() => {
|
|
690
|
+
const {height, width} = getContainerSize();
|
|
679
691
|
const style: ViewStyle = {
|
|
680
692
|
flexDirection: "column-reverse",
|
|
681
|
-
height
|
|
693
|
+
height,
|
|
682
694
|
justifyContent: "center",
|
|
683
695
|
top: offsetTop || offset,
|
|
684
|
-
width
|
|
696
|
+
width,
|
|
685
697
|
};
|
|
686
698
|
|
|
687
699
|
const data = toasts.filter((t) => t.placement === "center");
|
|
@@ -703,13 +715,28 @@ const ToastContainer = forwardRef<ToastContainerRef, ToastContainerProps>((props
|
|
|
703
715
|
);
|
|
704
716
|
}, [toasts, offset, offsetTop]);
|
|
705
717
|
|
|
706
|
-
|
|
718
|
+
const toastStack = (
|
|
707
719
|
<>
|
|
708
720
|
{renderTopToasts()}
|
|
709
721
|
{renderBottomToasts()}
|
|
710
722
|
{renderCenterToasts()}
|
|
711
723
|
</>
|
|
712
724
|
);
|
|
725
|
+
|
|
726
|
+
// react-native-web Modal appends its own node to document.body (z-index 9999).
|
|
727
|
+
// A position:fixed toast left in the app tree stays behind that layer and inherits
|
|
728
|
+
// the backdrop dim. Portal the same container to document.body so its z-index wins.
|
|
729
|
+
// Native keeps the in-tree absolute container.
|
|
730
|
+
if (Platform.OS !== "web") {
|
|
731
|
+
return toastStack;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
const portalTarget = resolveDocumentBodyPortalTarget();
|
|
735
|
+
if (!portalTarget) {
|
|
736
|
+
return toastStack;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
return createWebPortal({children: toastStack, container: portalTarget});
|
|
713
740
|
});
|
|
714
741
|
|
|
715
742
|
ToastContainer.displayName = "ToastContainer";
|