@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.
Files changed (186) hide show
  1. package/dist/AreaChart.d.ts +1 -1
  2. package/dist/AreaChart.d.ts.map +1 -1
  3. package/dist/AreaChart.js +70 -22
  4. package/dist/AreaChart.js.map +1 -1
  5. package/dist/Avatar.js +2 -2
  6. package/dist/Avatar.js.map +1 -1
  7. package/dist/BarChart.d.ts.map +1 -1
  8. package/dist/BarChart.js +55 -13
  9. package/dist/BarChart.js.map +1 -1
  10. package/dist/Button.js +2 -2
  11. package/dist/Button.js.map +1 -1
  12. package/dist/ChartCard.d.ts +5 -0
  13. package/dist/ChartCard.d.ts.map +1 -0
  14. package/dist/ChartCard.js +18 -0
  15. package/dist/ChartCard.js.map +1 -0
  16. package/dist/Common.d.ts +128 -5
  17. package/dist/Common.d.ts.map +1 -1
  18. package/dist/Common.js.map +1 -1
  19. package/dist/DashboardGrid.d.ts +6 -2
  20. package/dist/DashboardGrid.d.ts.map +1 -1
  21. package/dist/DashboardGrid.js +43 -10
  22. package/dist/DashboardGrid.js.map +1 -1
  23. package/dist/DateTimeActionSheet.js +2 -2
  24. package/dist/DateTimeActionSheet.js.map +1 -1
  25. package/dist/DateTimeField.js +3 -3
  26. package/dist/DateTimeField.js.map +1 -1
  27. package/dist/DonutChart.d.ts.map +1 -1
  28. package/dist/DonutChart.js +20 -10
  29. package/dist/DonutChart.js.map +1 -1
  30. package/dist/DropdownMenuItem.d.ts +16 -0
  31. package/dist/DropdownMenuItem.d.ts.map +1 -0
  32. package/dist/DropdownMenuItem.js +11 -0
  33. package/dist/DropdownMenuItem.js.map +1 -0
  34. package/dist/DropdownPanel.d.ts.map +1 -1
  35. package/dist/DropdownPanel.js +1 -1
  36. package/dist/DropdownPanel.js.map +1 -1
  37. package/dist/FilePickerButton.d.ts.map +1 -1
  38. package/dist/FilePickerButton.js +70 -10
  39. package/dist/FilePickerButton.js.map +1 -1
  40. package/dist/GPTChat.d.ts.map +1 -1
  41. package/dist/GPTChat.js +103 -14
  42. package/dist/GPTChat.js.map +1 -1
  43. package/dist/HeightField.js +2 -2
  44. package/dist/HeightField.js.map +1 -1
  45. package/dist/IconButton.d.ts.map +1 -1
  46. package/dist/IconButton.js +9 -6
  47. package/dist/IconButton.js.map +1 -1
  48. package/dist/LineChart.d.ts +1 -1
  49. package/dist/LineChart.d.ts.map +1 -1
  50. package/dist/LineChart.js +62 -21
  51. package/dist/LineChart.js.map +1 -1
  52. package/dist/MediaQuery.d.ts +10 -0
  53. package/dist/MediaQuery.d.ts.map +1 -1
  54. package/dist/MediaQuery.js +13 -1
  55. package/dist/MediaQuery.js.map +1 -1
  56. package/dist/MultiselectField.js +2 -2
  57. package/dist/MultiselectField.js.map +1 -1
  58. package/dist/RadioField.js +2 -2
  59. package/dist/RadioField.js.map +1 -1
  60. package/dist/Scorecard.d.ts +5 -0
  61. package/dist/Scorecard.d.ts.map +1 -0
  62. package/dist/Scorecard.js +11 -0
  63. package/dist/Scorecard.js.map +1 -0
  64. package/dist/SparklineChart.d.ts +5 -0
  65. package/dist/SparklineChart.d.ts.map +1 -0
  66. package/dist/SparklineChart.js +35 -0
  67. package/dist/SparklineChart.js.map +1 -0
  68. package/dist/SplitPage.d.ts +1 -1
  69. package/dist/SplitPage.d.ts.map +1 -1
  70. package/dist/SplitPage.js +126 -21
  71. package/dist/SplitPage.js.map +1 -1
  72. package/dist/TextField.d.ts.map +1 -1
  73. package/dist/TextField.js +12 -4
  74. package/dist/TextField.js.map +1 -1
  75. package/dist/ToastNotifications.d.ts.map +1 -1
  76. package/dist/ToastNotifications.js +29 -6
  77. package/dist/ToastNotifications.js.map +1 -1
  78. package/dist/UnifiedAddressAutoComplete.js +2 -2
  79. package/dist/UnifiedAddressAutoComplete.js.map +1 -1
  80. package/dist/WebDropdownMenu.d.ts +2 -1
  81. package/dist/WebDropdownMenu.d.ts.map +1 -1
  82. package/dist/WebDropdownMenu.js +2 -6
  83. package/dist/WebDropdownMenu.js.map +1 -1
  84. package/dist/charts/ChartFacadeContainer.d.ts +10 -0
  85. package/dist/charts/ChartFacadeContainer.d.ts.map +1 -0
  86. package/dist/charts/ChartFacadeContainer.js +10 -0
  87. package/dist/charts/ChartFacadeContainer.js.map +1 -0
  88. package/dist/charts/ChartFrame.d.ts +4 -0
  89. package/dist/charts/ChartFrame.d.ts.map +1 -1
  90. package/dist/charts/ChartFrame.js +4 -2
  91. package/dist/charts/ChartFrame.js.map +1 -1
  92. package/dist/charts/layout.d.ts +9 -2
  93. package/dist/charts/layout.d.ts.map +1 -1
  94. package/dist/charts/layout.js +28 -6
  95. package/dist/charts/layout.js.map +1 -1
  96. package/dist/charts/scales.d.ts +3 -1
  97. package/dist/charts/scales.d.ts.map +1 -1
  98. package/dist/charts/scales.js +7 -7
  99. package/dist/charts/scales.js.map +1 -1
  100. package/dist/charts/series.d.ts +15 -0
  101. package/dist/charts/series.d.ts.map +1 -0
  102. package/dist/charts/series.js +19 -0
  103. package/dist/charts/series.js.map +1 -0
  104. package/dist/charts/types/chartTypes.d.ts +7 -0
  105. package/dist/charts/types/chartTypes.d.ts.map +1 -1
  106. package/dist/dashboardGridLayout.d.ts +6 -0
  107. package/dist/dashboardGridLayout.d.ts.map +1 -1
  108. package/dist/dashboardGridLayout.js +19 -3
  109. package/dist/dashboardGridLayout.js.map +1 -1
  110. package/dist/fieldElements/FieldTitle.js +2 -2
  111. package/dist/fieldElements/FieldTitle.js.map +1 -1
  112. package/dist/index.d.ts +4 -1
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +1 -1
  115. package/dist/index.js.map +1 -1
  116. package/dist/lazyBoundaries/heavyOptionalExports.d.ts +9 -0
  117. package/dist/lazyBoundaries/heavyOptionalExports.d.ts.map +1 -1
  118. package/dist/lazyBoundaries/heavyOptionalExports.js +6 -0
  119. package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -1
  120. package/dist/resolveDocumentBodyPortalTarget.d.ts +7 -0
  121. package/dist/resolveDocumentBodyPortalTarget.d.ts.map +1 -0
  122. package/dist/resolveDocumentBodyPortalTarget.js +12 -0
  123. package/dist/resolveDocumentBodyPortalTarget.js.map +1 -0
  124. package/package.json +1 -1
  125. package/src/AIRequestExplorer.test.tsx +2 -2
  126. package/src/AreaChart.test.tsx +81 -0
  127. package/src/AreaChart.tsx +171 -62
  128. package/src/Avatar.tsx +2 -2
  129. package/src/BarChart.test.tsx +119 -0
  130. package/src/BarChart.tsx +94 -20
  131. package/src/Button.test.tsx +7 -7
  132. package/src/Button.tsx +2 -2
  133. package/src/ChartCard.test.tsx +79 -0
  134. package/src/ChartCard.tsx +80 -0
  135. package/src/Common.ts +119 -2
  136. package/src/DashboardGrid.test.tsx +98 -1
  137. package/src/DashboardGrid.tsx +71 -20
  138. package/src/DateTimeActionSheet.tsx +4 -4
  139. package/src/DateTimeField.test.tsx +5 -4
  140. package/src/DateTimeField.tsx +3 -3
  141. package/src/DonutChart.test.tsx +73 -0
  142. package/src/DonutChart.tsx +87 -14
  143. package/src/DropdownMenuItem.tsx +48 -0
  144. package/src/DropdownPanel.test.tsx +12 -0
  145. package/src/DropdownPanel.tsx +8 -1
  146. package/src/FilePickerButton.test.tsx +60 -6
  147. package/src/FilePickerButton.tsx +116 -28
  148. package/src/GPTChat.test.tsx +133 -6
  149. package/src/GPTChat.tsx +196 -38
  150. package/src/HeightField.tsx +2 -2
  151. package/src/IconButton.test.tsx +63 -0
  152. package/src/IconButton.tsx +10 -5
  153. package/src/LineChart.test.tsx +104 -0
  154. package/src/LineChart.tsx +154 -58
  155. package/src/MediaQuery.ts +14 -1
  156. package/src/MultiselectField.tsx +2 -2
  157. package/src/RadioField.tsx +2 -2
  158. package/src/Scorecard.test.tsx +65 -0
  159. package/src/Scorecard.tsx +45 -0
  160. package/src/SparklineChart.test.tsx +69 -0
  161. package/src/SparklineChart.tsx +85 -0
  162. package/src/SplitPage.test.tsx +449 -11
  163. package/src/SplitPage.tsx +255 -21
  164. package/src/TextField.test.tsx +16 -0
  165. package/src/TextField.tsx +13 -3
  166. package/src/ToastNotifications.tsx +33 -6
  167. package/src/ToastNotifications.webModal.test.tsx +285 -0
  168. package/src/UnifiedAddressAutoComplete.test.tsx +4 -4
  169. package/src/UnifiedAddressAutoComplete.tsx +2 -2
  170. package/src/WebDropdownMenu.tsx +3 -7
  171. package/src/__snapshots__/DropdownPanel.test.tsx.snap +3 -1
  172. package/src/bunSetup.ts +3 -1
  173. package/src/charts/ChartFacadeContainer.tsx +35 -0
  174. package/src/charts/ChartFrame.tsx +39 -1
  175. package/src/charts/layout.test.ts +22 -1
  176. package/src/charts/layout.ts +37 -4
  177. package/src/charts/scales.test.ts +33 -0
  178. package/src/charts/scales.ts +10 -6
  179. package/src/charts/series.ts +43 -0
  180. package/src/charts/types/chartTypes.ts +8 -0
  181. package/src/dashboardGridLayout.test.ts +59 -1
  182. package/src/dashboardGridLayout.ts +30 -3
  183. package/src/fieldElements/FieldTitle.tsx +2 -2
  184. package/src/index.tsx +6 -0
  185. package/src/lazyBoundaries/heavyOptionalExports.tsx +21 -0
  186. package/src/resolveDocumentBodyPortalTarget.ts +11 -0
@@ -4,7 +4,7 @@ import {assert} from "chai";
4
4
 
5
5
  import {Button} from "./Button";
6
6
  import type {ButtonProps} from "./Common";
7
- import {isMobileDevice} from "./MediaQuery";
7
+ import {isNarrowViewport} from "./MediaQuery";
8
8
  import * as ThemeModule from "./Theme";
9
9
  import {renderWithIcons, renderWithTheme, TEST_CUSTOM_ICON_TEST_ID} from "./test-utils";
10
10
  import {Unifier} from "./Unifier";
@@ -228,7 +228,7 @@ describe("Button", () => {
228
228
 
229
229
  it("skips equivalent parent updates and redraws changed props", () => {
230
230
  const handleClick = mock(() => Promise.resolve());
231
- const mobileDeviceMock = isMobileDevice as ReturnType<typeof mock>;
231
+ const mobileDeviceMock = isNarrowViewport as ReturnType<typeof mock>;
232
232
  mobileDeviceMock.mockClear();
233
233
  const {rerender} = renderWithTheme(<Button onClick={handleClick} text="Stable" />);
234
234
  const initialRenderCalls = mobileDeviceMock.mock.calls.length;
@@ -615,9 +615,9 @@ describe("Button", () => {
615
615
  expect(tree).toBeTruthy();
616
616
  });
617
617
 
618
- it("does not render tooltip wrapper when isMobileDevice is true", () => {
618
+ it("does not render tooltip wrapper when isNarrowViewport is true", () => {
619
619
  const nativeSpy = spyOn(Utilities, "isNative").mockReturnValue(false);
620
- (isMobileDevice as ReturnType<typeof mock>).mockImplementation(() => true);
620
+ (isNarrowViewport as ReturnType<typeof mock>).mockImplementation(() => true);
621
621
 
622
622
  const {getByText, toJSON} = renderWithTheme(
623
623
  <Button onClick={() => {}} text="No Tooltip" tooltipText="Should not wrap" />
@@ -627,12 +627,12 @@ describe("Button", () => {
627
627
  const tree = JSON.stringify(toJSON());
628
628
  expect(tree).not.toContain("Should not wrap");
629
629
  nativeSpy.mockRestore();
630
- (isMobileDevice as ReturnType<typeof mock>).mockImplementation(() => false);
630
+ (isNarrowViewport as ReturnType<typeof mock>).mockImplementation(() => false);
631
631
  });
632
632
 
633
633
  it("renders tooltip wrapper when tooltipText is provided and not native", () => {
634
634
  const nativeSpy = spyOn(Utilities, "isNative").mockReturnValue(false);
635
- (isMobileDevice as ReturnType<typeof mock>).mockImplementation(() => false);
635
+ (isNarrowViewport as ReturnType<typeof mock>).mockImplementation(() => false);
636
636
 
637
637
  const {getByText} = renderWithTheme(
638
638
  <Button onClick={() => {}} text="With Tooltip" tooltipText="Helpful tip" />
@@ -640,7 +640,7 @@ describe("Button", () => {
640
640
 
641
641
  expect(getByText("With Tooltip")).toBeTruthy();
642
642
  nativeSpy.mockRestore();
643
- (isMobileDevice as ReturnType<typeof mock>).mockImplementation(() => false);
643
+ (isNarrowViewport as ReturnType<typeof mock>).mockImplementation(() => false);
644
644
  });
645
645
 
646
646
  it("resets loading and rethrows when onClick rejects", async () => {
package/src/Button.tsx CHANGED
@@ -13,7 +13,7 @@ import {ActivityIndicator, Pressable, type PressableProps, Text, View} from "rea
13
13
  import {Box} from "./Box";
14
14
  import type {ButtonPressAnimation, ButtonProps} from "./Common";
15
15
  import {useCustomIcon} from "./IconRegistry";
16
- import {isMobileDevice} from "./MediaQuery";
16
+ import {isNarrowViewport} from "./MediaQuery";
17
17
  import {useTheme} from "./Theme";
18
18
  import {Tooltip} from "./Tooltip";
19
19
  import {Unifier} from "./Unifier";
@@ -307,7 +307,7 @@ const ConfirmationButton: React.FC<ButtonProps> = ({
307
307
 
308
308
  const ButtonRender: React.FC<ButtonProps> = (props) => {
309
309
  const {tooltipText, tooltipIdealPosition, tooltipIncludeArrow = false} = props;
310
- const isMobileOrNative = isMobileDevice() || isNative();
310
+ const isMobileOrNative = isNarrowViewport() || isNative();
311
311
  const button = props.withConfirmation ? (
312
312
  <ConfirmationButton {...props} />
313
313
  ) : (
@@ -0,0 +1,79 @@
1
+ import {describe, it} from "bun:test";
2
+ import {fireEvent} from "@testing-library/react-native";
3
+ import {assert} from "chai";
4
+
5
+ import {ChartCard} from "./ChartCard";
6
+ import {ChartCard as RootChartCard} from "./index";
7
+ import {Text} from "./Text";
8
+ import {renderWithTheme} from "./test-utils";
9
+
10
+ describe("ChartCard", () => {
11
+ it("renders title, filter summary, period badge, and children", () => {
12
+ const {getByText} = renderWithTheme(
13
+ <ChartCard
14
+ filterSummary="Report filters: status is Eligible"
15
+ periodLabel="Last 30 days"
16
+ title="Cost by Device"
17
+ >
18
+ <Text>Chart body</Text>
19
+ </ChartCard>
20
+ );
21
+
22
+ assert.exists(getByText("Cost by Device"));
23
+ assert.exists(getByText("Report filters: status is Eligible"));
24
+ assert.exists(getByText("Last 30 days"));
25
+ assert.exists(getByText("Chart body"));
26
+ });
27
+
28
+ it("makes the period badge pressable only when a handler is provided", async (): Promise<void> => {
29
+ let pressCount = 0;
30
+ const handlePeriodPress = (): void => {
31
+ pressCount += 1;
32
+ };
33
+ const interactive = renderWithTheme(
34
+ <ChartCard
35
+ onPeriodPress={handlePeriodPress}
36
+ periodLabel="Last 14 days"
37
+ testID="cost-card"
38
+ title="Cost"
39
+ >
40
+ <Text>Body</Text>
41
+ </ChartCard>
42
+ );
43
+
44
+ const periodButton = interactive.getByTestId("cost-card.period-clickable");
45
+ assert.equal(periodButton.props.accessibilityRole, "button");
46
+ assert.equal(periodButton.props["aria-label"], "Last 14 days");
47
+ assert.equal(periodButton.props.accessibilityHint, "Change reporting period");
48
+ fireEvent.press(periodButton);
49
+ await new Promise((resolve) => setTimeout(resolve, 0));
50
+ assert.equal(pressCount, 1);
51
+
52
+ const displayOnly = renderWithTheme(
53
+ <ChartCard periodLabel="Previous period" testID="display-card" title="Cost">
54
+ <Text>Body</Text>
55
+ </ChartCard>
56
+ );
57
+ assert.notExists(displayOnly.queryByTestId("display-card.period-clickable"));
58
+ assert.notEqual(
59
+ displayOnly.getByTestId("display-card.period").props.accessibilityRole,
60
+ "button"
61
+ );
62
+ });
63
+
64
+ it("omits optional period and filter chrome", () => {
65
+ const {queryByTestId, queryByText} = renderWithTheme(
66
+ <ChartCard testID="plain-card" title="Conversions">
67
+ <Text>Body</Text>
68
+ </ChartCard>
69
+ );
70
+
71
+ assert.notExists(queryByTestId("plain-card.period"));
72
+ assert.notExists(queryByTestId("plain-card.filter-summary"));
73
+ assert.notExists(queryByText("Last 30 days"));
74
+ });
75
+
76
+ it("is available from the package root lazy boundary", () => {
77
+ assert.isFunction(RootChartCard);
78
+ });
79
+ });
@@ -0,0 +1,80 @@
1
+ import type {FC} from "react";
2
+
3
+ import {Badge} from "./Badge";
4
+ import {Box} from "./Box";
5
+ import {Card} from "./Card";
6
+ import type {ChartCardProps} from "./Common";
7
+ import {Heading} from "./Heading";
8
+ import {Text} from "./Text";
9
+ import {resolveTestID} from "./testing/resolveTestId";
10
+
11
+ interface PeriodBadgeProps {
12
+ label: string;
13
+ onPress?: () => void;
14
+ testID?: string;
15
+ }
16
+
17
+ const PeriodBadge: FC<PeriodBadgeProps> = ({label, onPress, testID}) => {
18
+ const badge = (
19
+ <Badge
20
+ secondary
21
+ status="active"
22
+ testID={onPress ? resolveTestID(testID, "badge") : testID}
23
+ value={label}
24
+ />
25
+ );
26
+
27
+ if (onPress) {
28
+ return (
29
+ <Box
30
+ accessibilityHint="Change reporting period"
31
+ accessibilityLabel={label}
32
+ accessibilityRole="button"
33
+ onClick={onPress}
34
+ testID={testID}
35
+ >
36
+ {badge}
37
+ </Box>
38
+ );
39
+ }
40
+
41
+ return badge;
42
+ };
43
+
44
+ export const ChartCard: FC<ChartCardProps> = ({
45
+ children,
46
+ filterSummary,
47
+ onPeriodPress,
48
+ periodLabel,
49
+ testID,
50
+ title,
51
+ }) => {
52
+ return (
53
+ <Card gap={3} padding={4} testID={testID}>
54
+ <Box alignItems="start" direction="row" gap={2} justifyContent="between" width="100%">
55
+ <Box flex="grow" minWidth={0}>
56
+ <Heading size="sm" testID={resolveTestID(testID, "title")}>
57
+ {title}
58
+ </Heading>
59
+ </Box>
60
+ {periodLabel ? (
61
+ <PeriodBadge
62
+ label={periodLabel}
63
+ onPress={onPeriodPress}
64
+ testID={resolveTestID(testID, "period")}
65
+ />
66
+ ) : null}
67
+ </Box>
68
+ {filterSummary ? (
69
+ <Text color="secondaryDark" size="sm" testID={resolveTestID(testID, "filter-summary")}>
70
+ {filterSummary}
71
+ </Text>
72
+ ) : null}
73
+ <Box minWidth={0} width="100%">
74
+ {children}
75
+ </Box>
76
+ </Card>
77
+ );
78
+ };
79
+
80
+ export type {ChartCardProps} from "./Common";
package/src/Common.ts CHANGED
@@ -19,6 +19,7 @@ import type {
19
19
  FontAwesome6RegularNames,
20
20
  FontAwesome6SolidNames,
21
21
  } from "./CommonIconTypes";
22
+ import type {ChartPoint, ChartSeries} from "./charts/types/chartTypes";
22
23
  import type {DropdownPanelAlign} from "./dropdownPanelLayout";
23
24
  import type {
24
25
  DataTableTestIDs,
@@ -993,6 +994,11 @@ export interface TextFieldProps extends BaseFieldProps, HelperTextProps, ErrorTe
993
994
  returnKeyType?: "done" | "go" | "next" | "search" | "send";
994
995
 
995
996
  grow?: boolean;
997
+ /**
998
+ * Caps the height (in pixels) a `grow` field expands to. Past the cap the field
999
+ * stops growing and its content scrolls.
1000
+ */
1001
+ maxHeight?: number;
996
1002
  multiline?: boolean;
997
1003
  rows?: number;
998
1004
 
@@ -1207,6 +1213,50 @@ export interface SplitPageProps<TItem extends SplitPageListItem = SplitPageListI
1207
1213
  listViewMaxWidth?: number;
1208
1214
  renderChild?: () => ReactChild;
1209
1215
  onSelectionChange?: (value?: ListRenderItemInfo<TItem>) => void | Promise<void>;
1216
+ /**
1217
+ * Web only. The native SplitPage ignores this prop.
1218
+ * Use the narrow layout when the window width is less than or equal to this many pixels.
1219
+ * When omitted, the narrow layout follows `isNarrowViewport()`.
1220
+ */
1221
+ narrowBelowWidth?: number;
1222
+ /**
1223
+ * Web only. The native SplitPage ignores this prop.
1224
+ * Minimum width, in pixels, of each child in the desktop side-by-side layout.
1225
+ * Applies only when the viewport is not narrow and there are 1 or 2 non-null children.
1226
+ * When omitted, that layout stays a flex row. When there are more than 2 children, the
1227
+ * segmented-control layout is used and this prop is ignored.
1228
+ */
1229
+ desktopChildrenMinWidth?: number;
1230
+ /**
1231
+ * Web only. The native SplitPage ignores this prop.
1232
+ * Opt-in labels for the narrow-viewport full-width pager, one per non-null child, in child
1233
+ * order. The pager is active only when the narrow layout is active, a detail view is active,
1234
+ * there is more than one non-null child, and this array's length equals that child count.
1235
+ * Otherwise the dotted swiper is used. A length mismatch is ignored and falls back to the
1236
+ * dotted swiper.
1237
+ */
1238
+ narrowViewportChildLabels?: string[];
1239
+ /**
1240
+ * Web only. The native SplitPage ignores this prop.
1241
+ * When true, the narrow detail view is active even if the internal list selection is unset.
1242
+ * Detail is active when the internal selection is set or this flag is true.
1243
+ * Showing the list clears only the internal selection. The parent turns this flag off.
1244
+ */
1245
+ narrowViewportSelectionActive?: boolean;
1246
+ /**
1247
+ * Web only. The native SplitPage ignores this prop.
1248
+ * Identity of the record the parent selected.
1249
+ * When this string changes, the narrow pager resets to the first child.
1250
+ * Width and layout measurement changes do not reset it.
1251
+ */
1252
+ narrowViewportSelectionKey?: string;
1253
+ /**
1254
+ * Web only. The native SplitPage ignores this prop.
1255
+ * When set on the opt-in narrow pager, show a return-to-list button that clears the
1256
+ * internal selection and calls onSelectionChange with undefined.
1257
+ * When omitted, that button is not rendered.
1258
+ */
1259
+ narrowViewportListButtonLabel?: string;
1210
1260
  }
1211
1261
 
1212
1262
  export type PermissionKind =
@@ -2335,6 +2385,12 @@ export interface IconButtonProps extends WithTestID {
2335
2385
  */
2336
2386
  variant?: "primary" | "secondary" | "muted" | "destructive" | "navigation" | "ghost";
2337
2387
 
2388
+ /**
2389
+ * When set, the variant background is passed through applyColorOpacity and the icon color
2390
+ * stays the opaque variant color. When omitted, the background is unchanged.
2391
+ */
2392
+ backgroundOpacity?: number;
2393
+
2338
2394
  /**
2339
2395
  * If true, a confirmation modal will be shown before the onClick action.
2340
2396
  * @default false
@@ -2684,8 +2740,10 @@ export interface PaginationProps extends WithTestID {
2684
2740
  export interface LineChartProps extends WithTestID {
2685
2741
  /** Summary announced for the whole chart. */
2686
2742
  accessibilityLabel?: string;
2743
+ /** Optional previous-period values drawn as a dotted overlay. */
2744
+ comparisonData?: ChartPoint[];
2687
2745
  /** Single series of labeled numeric points. */
2688
- data: Array<{color?: string; label: string; value: number}>;
2746
+ data: ChartPoint[];
2689
2747
  /** Copy shown when `data` is empty. */
2690
2748
  emptyText?: string;
2691
2749
  /** Formats the numeric value in tooltips. */
@@ -2696,12 +2754,65 @@ export interface LineChartProps extends WithTestID {
2696
2754
  legendLabel?: string;
2697
2755
  /** When true, shows a spinner instead of the plot. */
2698
2756
  loading?: boolean;
2757
+ /** Makes `periodLabel` pressable when provided. */
2758
+ onPeriodPress?: () => void;
2759
+ /** Relative or absolute reporting period shown with `title`. */
2760
+ periodLabel?: string;
2761
+ /** Named series. When non-empty, these replace the single `data` series. */
2762
+ series?: ChartSeries[];
2763
+ /** Optional chart-card title shortcut. */
2764
+ title?: string;
2765
+ /** X-label collision policy. `auto` rotates when more than seven labels are present. */
2766
+ xTickPolicy?: "auto" | "rotate" | "truncate";
2767
+ }
2768
+
2769
+ export interface SparklineChartProps extends WithTestID {
2770
+ /** Summary announced for the whole sparkline. */
2771
+ accessibilityLabel?: string;
2772
+ /** Optional previous-period values drawn as a dotted line. */
2773
+ comparisonData?: Array<{label: string; value: number}>;
2774
+ /** Current labeled numeric values. */
2775
+ data: Array<{label: string; value: number}>;
2776
+ /** Whole sparkline height in pixels. */
2777
+ height?: number;
2778
+ }
2779
+
2780
+ export interface ChartCardProps extends WithTestID {
2781
+ children: React.ReactNode;
2782
+ /** Optional context shown below the title row. */
2783
+ filterSummary?: string;
2784
+ /** Makes the period badge pressable when provided. */
2785
+ onPeriodPress?: () => void;
2786
+ /** Date range or relative period shown in the header. */
2787
+ periodLabel?: string;
2788
+ /** Card heading. */
2789
+ title: string;
2790
+ }
2791
+
2792
+ export interface ScorecardProps extends WithTestID {
2793
+ /** Optional previous-period sparkline values. */
2794
+ comparisonData?: Array<{label: string; value: number}>;
2795
+ /** Formats numeric values. String values render unchanged. */
2796
+ formatValue?: (value: number) => string;
2797
+ onPeriodPress?: () => void;
2798
+ periodLabel?: string;
2799
+ /** Current-period sparkline values. */
2800
+ sparklineData?: Array<{label: string; value: number}>;
2801
+ title: string;
2802
+ value: number | string;
2699
2803
  }
2700
2804
 
2701
2805
  export interface AreaChartProps extends LineChartProps {}
2702
2806
  export interface BarChartProps extends LineChartProps {}
2703
2807
 
2704
- export interface DonutChartProps extends LineChartProps {}
2808
+ export interface DonutChartProps extends LineChartProps {
2809
+ /** Small copy below the center value. */
2810
+ centerTitle?: string;
2811
+ /** Primary copy inside the donut hole. */
2812
+ centerValue?: string;
2813
+ /** Formats each slice's legend share. Defaults to a rounded percentage. */
2814
+ formatShare?: (value: number, total: number) => string;
2815
+ }
2705
2816
 
2706
2817
  export interface DashboardGridProps extends WithTestID {
2707
2818
  children?: React.ReactNode;
@@ -2710,6 +2821,12 @@ export interface DashboardGridProps extends WithTestID {
2710
2821
  gap?: UnsignedUpTo12;
2711
2822
  }
2712
2823
 
2824
+ export interface DashboardGridItemProps extends WithTestID {
2825
+ children?: React.ReactNode;
2826
+ /** Number of grid columns occupied at each breakpoint. Defaults to one. */
2827
+ span?: {lg?: number; md?: number; sm?: number};
2828
+ }
2829
+
2713
2830
  /**
2714
2831
  * Data Table
2715
2832
  */
@@ -1,12 +1,17 @@
1
1
  import {describe, expect, it} from "bun:test";
2
2
  import {act, fireEvent} from "@testing-library/react-native";
3
+ import {assert} from "chai";
4
+ import {memo} from "react";
3
5
 
4
6
  import {Box} from "./Box";
5
7
  import {getSpacing} from "./Common";
6
- import {DashboardGrid} from "./DashboardGrid";
8
+ import {DashboardGrid, DashboardGridItem} from "./DashboardGrid";
7
9
  import {getDashboardCellWidth} from "./dashboardGridLayout";
10
+ import {sharedResponsiveBreakpointStore} from "./ResponsiveBreakpoint";
8
11
  import {renderWithTheme} from "./test-utils";
9
12
 
13
+ const MemoDashboardGridItem = memo(DashboardGridItem);
14
+
10
15
  describe("DashboardGrid", () => {
11
16
  it("keeps child testIDs", () => {
12
17
  const {getByTestId} = renderWithTheme(
@@ -72,4 +77,96 @@ describe("DashboardGrid", () => {
72
77
  width: expectedWidth,
73
78
  });
74
79
  });
80
+
81
+ it("lets an item span responsive column units without changing plain children", async () => {
82
+ const {getByTestId} = renderWithTheme(
83
+ <DashboardGrid columns={{lg: 4, md: 4, sm: 4}} gap={4} testID="grid">
84
+ <DashboardGridItem span={{lg: 2, md: 2, sm: 2}} testID="wide-item">
85
+ <Box>Wide</Box>
86
+ </DashboardGridItem>
87
+ <Box testID="plain-item">Plain</Box>
88
+ </DashboardGrid>
89
+ );
90
+
91
+ await act(async () => {
92
+ fireEvent(getByTestId("grid"), "layout", {
93
+ nativeEvent: {layout: {height: 80, width: 332}},
94
+ });
95
+ });
96
+
97
+ const baseWidth = getDashboardCellWidth({
98
+ columnCount: 4,
99
+ gapPx: getSpacing(4),
100
+ rowWidth: 332,
101
+ });
102
+ assert.include(getByTestId("grid.cell.0").props.style, {
103
+ width: baseWidth * 2 + getSpacing(4),
104
+ });
105
+ assert.include(getByTestId("grid.cell.1").props.style, {width: baseWidth});
106
+ assert.exists(getByTestId("wide-item"));
107
+ assert.exists(getByTestId("plain-item"));
108
+ });
109
+
110
+ it("resolves asymmetric spans at each responsive breakpoint", async () => {
111
+ const result = renderWithTheme(
112
+ <DashboardGrid columns={{lg: 4, md: 4, sm: 4}} gap={4} testID="grid">
113
+ <DashboardGridItem span={{lg: 3, md: 2, sm: 1}}>
114
+ <Box>Responsive</Box>
115
+ </DashboardGridItem>
116
+ </DashboardGrid>
117
+ );
118
+ await act(async () => {
119
+ fireEvent(result.getByTestId("grid"), "layout", {
120
+ nativeEvent: {layout: {height: 80, width: 332}},
121
+ });
122
+ sharedResponsiveBreakpointStore.updateWidth(319);
123
+ });
124
+ const baseWidth = getDashboardCellWidth({
125
+ columnCount: 4,
126
+ gapPx: getSpacing(4),
127
+ rowWidth: 332,
128
+ });
129
+ assert.equal(result.getByTestId("grid.cell.0").props.style.width, baseWidth);
130
+
131
+ act((): void => {
132
+ sharedResponsiveBreakpointStore.updateWidth(375);
133
+ });
134
+ assert.equal(
135
+ result.getByTestId("grid.cell.0").props.style.width,
136
+ baseWidth * 2 + getSpacing(4)
137
+ );
138
+
139
+ act((): void => {
140
+ sharedResponsiveBreakpointStore.updateWidth(600);
141
+ });
142
+ assert.equal(
143
+ result.getByTestId("grid.cell.0").props.style.width,
144
+ baseWidth * 3 + getSpacing(4) * 2
145
+ );
146
+
147
+ result.unmount();
148
+ sharedResponsiveBreakpointStore.updateWidth(375);
149
+ });
150
+
151
+ it("keeps span metadata through React memo wrappers", async () => {
152
+ const {getByTestId} = renderWithTheme(
153
+ <DashboardGrid columns={{lg: 4, md: 4, sm: 4}} gap={4} testID="grid">
154
+ <MemoDashboardGridItem span={{lg: 2, md: 2, sm: 2}}>
155
+ <Box>Memo item</Box>
156
+ </MemoDashboardGridItem>
157
+ </DashboardGrid>
158
+ );
159
+ await act(async () => {
160
+ fireEvent(getByTestId("grid"), "layout", {
161
+ nativeEvent: {layout: {height: 80, width: 332}},
162
+ });
163
+ });
164
+ const baseWidth = getDashboardCellWidth({
165
+ columnCount: 4,
166
+ gapPx: getSpacing(4),
167
+ rowWidth: 332,
168
+ });
169
+
170
+ assert.equal(getByTestId("grid.cell.0").props.style.width, baseWidth * 2 + getSpacing(4));
171
+ });
75
172
  });
@@ -1,15 +1,19 @@
1
1
  import type {FC, ReactNode} from "react";
2
- import {Children, useCallback, useState} from "react";
2
+ import {Children, isValidElement, useCallback, useState} from "react";
3
3
 
4
4
  import {Box} from "./Box";
5
- import type {DashboardGridProps, LayoutChangeEvent} from "./Common";
5
+ import type {DashboardGridItemProps, DashboardGridProps, LayoutChangeEvent} from "./Common";
6
6
  import {getSpacing} from "./Common";
7
- import {getDashboardCellBoxStyle} from "./dashboardGridLayout";
7
+ import {getDashboardSpanCellBoxStyle} from "./dashboardGridLayout";
8
8
  import {useResponsiveBreakpoint} from "./ResponsiveBreakpoint";
9
9
  import {resolveTestID} from "./testing/resolveTestId";
10
10
 
11
11
  const DEFAULT_COLUMNS = {lg: 3, md: 2, sm: 1};
12
12
 
13
+ type MarkedDashboardGridItem = FC<DashboardGridItemProps> & {
14
+ isDashboardGridItem?: boolean;
15
+ };
16
+
13
17
  const resolveColumnCount = ({
14
18
  breakpoint,
15
19
  columns,
@@ -26,6 +30,44 @@ const resolveColumnCount = ({
26
30
  return columns.sm;
27
31
  };
28
32
 
33
+ const resolveItemSpan = ({
34
+ breakpoint,
35
+ span,
36
+ }: {
37
+ breakpoint: "xs" | "sm" | "md" | "lg" | "xl";
38
+ span?: DashboardGridItemProps["span"];
39
+ }): number => {
40
+ if (!span) {
41
+ return 1;
42
+ }
43
+ if (breakpoint === "lg" || breakpoint === "xl") {
44
+ return span.lg ?? span.md ?? span.sm ?? 1;
45
+ }
46
+ if (breakpoint === "md") {
47
+ return span.md ?? span.sm ?? 1;
48
+ }
49
+ return span.sm ?? 1;
50
+ };
51
+
52
+ export const DashboardGridItem: MarkedDashboardGridItem = ({children, testID}) => {
53
+ return (
54
+ <Box minWidth={0} testID={testID} width="100%">
55
+ {children}
56
+ </Box>
57
+ );
58
+ };
59
+ DashboardGridItem.isDashboardGridItem = true;
60
+
61
+ const isDashboardGridItemType = (type: unknown): boolean => {
62
+ if (typeof type === "function") {
63
+ return (type as MarkedDashboardGridItem).isDashboardGridItem === true;
64
+ }
65
+ if (type && typeof type === "object" && "type" in type) {
66
+ return isDashboardGridItemType(type.type);
67
+ }
68
+ return false;
69
+ };
70
+
29
71
  export const DashboardGrid: FC<DashboardGridProps> = ({
30
72
  children,
31
73
  columns = DEFAULT_COLUMNS,
@@ -36,11 +78,7 @@ export const DashboardGrid: FC<DashboardGridProps> = ({
36
78
  const breakpoint = useResponsiveBreakpoint({enabled: true});
37
79
  const [rowWidth, setRowWidth] = useState(0);
38
80
  const columnCount = Math.max(resolveColumnCount({breakpoint, columns}), 1);
39
- const cellStyle = getDashboardCellBoxStyle({
40
- columnCount,
41
- gapPx: getSpacing(gap),
42
- rowWidth,
43
- });
81
+ const gapPx = getSpacing(gap);
44
82
 
45
83
  const handleLayout = useCallback((event: LayoutChangeEvent): void => {
46
84
  const nextWidth = event.nativeEvent.layout.width;
@@ -51,19 +89,32 @@ export const DashboardGrid: FC<DashboardGridProps> = ({
51
89
 
52
90
  return (
53
91
  <Box direction="row" gap={gap} onLayout={handleLayout} testID={testID} width="100%" wrap>
54
- {renderedChildren.map((child: ReactNode, index: number) => (
55
- <Box
56
- dangerouslySetInlineStyle={{
57
- __style: cellStyle,
58
- }}
59
- key={`dashboard-cell-${index}`}
60
- testID={resolveTestID(testID, `cell.${index}`)}
61
- >
62
- {child}
63
- </Box>
64
- ))}
92
+ {renderedChildren.map((child: ReactNode, index: number) => {
93
+ const itemSpan =
94
+ isValidElement<DashboardGridItemProps>(child) && isDashboardGridItemType(child.type)
95
+ ? child.props.span
96
+ : undefined;
97
+ const span = resolveItemSpan({breakpoint, span: itemSpan});
98
+ const cellStyle = getDashboardSpanCellBoxStyle({
99
+ columnCount,
100
+ gapPx,
101
+ rowWidth,
102
+ span,
103
+ });
104
+ return (
105
+ <Box
106
+ dangerouslySetInlineStyle={{
107
+ __style: cellStyle,
108
+ }}
109
+ key={`dashboard-cell-${index}`}
110
+ testID={resolveTestID(testID, `cell.${index}`)}
111
+ >
112
+ {child}
113
+ </Box>
114
+ );
115
+ })}
65
116
  </Box>
66
117
  );
67
118
  };
68
119
 
69
- export type {DashboardGridProps} from "./Common";
120
+ export type {DashboardGridItemProps, DashboardGridProps} from "./Common";
@@ -11,7 +11,7 @@ import {Calendar} from "react-native-calendars";
11
11
  import {Box} from "./Box";
12
12
  import type {DateTimeActionSheetProps, IconName} from "./Common";
13
13
  import {Heading} from "./Heading";
14
- import {isMobileDevice} from "./MediaQuery";
14
+ import {isNarrowViewport} from "./MediaQuery";
15
15
  import {Modal} from "./Modal";
16
16
  import {SelectField} from "./SelectField";
17
17
  import {useTheme} from "./Theme";
@@ -591,14 +591,14 @@ export const DateTimeActionSheet = ({
591
591
  >
592
592
  <View style={{display: "flex", justifyContent: "center", width: "100%"}}>
593
593
  {Boolean(type === "date") && <DateCalendar {...dateProps} />}
594
- {Boolean(type === "time" && isMobileDevice()) && <MobileTime {...timeProps} />}
595
- {Boolean(type === "time" && !isMobileDevice()) && <WebTime {...timeProps} />}
594
+ {Boolean(type === "time" && isNarrowViewport()) && <MobileTime {...timeProps} />}
595
+ {Boolean(type === "time" && !isNarrowViewport()) && <WebTime {...timeProps} />}
596
596
  {Boolean(type === "datetime") && (
597
597
  <Box>
598
598
  <Box marginBottom={2}>
599
599
  <DateCalendar {...dateProps} />
600
600
  </Box>
601
- {isMobileDevice() ? <MobileTime {...timeProps} /> : <WebTime {...timeProps} />}
601
+ {isNarrowViewport() ? <MobileTime {...timeProps} /> : <WebTime {...timeProps} />}
602
602
  </Box>
603
603
  )}
604
604
  </View>