@terreno/ui 57.8.0 → 57.10.1

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 (269) hide show
  1. package/README.md +2 -0
  2. package/dist/AreaChart.d.ts +1 -1
  3. package/dist/AreaChart.d.ts.map +1 -1
  4. package/dist/AreaChart.js +70 -22
  5. package/dist/AreaChart.js.map +1 -1
  6. package/dist/BarChart.d.ts.map +1 -1
  7. package/dist/BarChart.js +55 -13
  8. package/dist/BarChart.js.map +1 -1
  9. package/dist/Button.d.ts.map +1 -1
  10. package/dist/Button.js +19 -4
  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 +147 -6
  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/DateTimeField.d.ts.map +1 -1
  24. package/dist/DateTimeField.js +90 -17
  25. package/dist/DateTimeField.js.map +1 -1
  26. package/dist/DonutChart.d.ts.map +1 -1
  27. package/dist/DonutChart.js +20 -10
  28. package/dist/DonutChart.js.map +1 -1
  29. package/dist/DropdownMenuItem.d.ts +16 -0
  30. package/dist/DropdownMenuItem.d.ts.map +1 -0
  31. package/dist/DropdownMenuItem.js +11 -0
  32. package/dist/DropdownMenuItem.js.map +1 -0
  33. package/dist/FilePickerButton.d.ts +15 -1
  34. package/dist/FilePickerButton.d.ts.map +1 -1
  35. package/dist/FilePickerButton.js +90 -13
  36. package/dist/FilePickerButton.js.map +1 -1
  37. package/dist/GPTChat.d.ts +57 -1
  38. package/dist/GPTChat.d.ts.map +1 -1
  39. package/dist/GPTChat.js +301 -20
  40. package/dist/GPTChat.js.map +1 -1
  41. package/dist/HtmlFrame.d.ts +11 -0
  42. package/dist/HtmlFrame.d.ts.map +1 -0
  43. package/dist/HtmlFrame.js +29 -0
  44. package/dist/HtmlFrame.js.map +1 -0
  45. package/dist/LineChart.d.ts +1 -1
  46. package/dist/LineChart.d.ts.map +1 -1
  47. package/dist/LineChart.js +62 -21
  48. package/dist/LineChart.js.map +1 -1
  49. package/dist/Scorecard.d.ts +5 -0
  50. package/dist/Scorecard.d.ts.map +1 -0
  51. package/dist/Scorecard.js +11 -0
  52. package/dist/Scorecard.js.map +1 -0
  53. package/dist/SparklineChart.d.ts +5 -0
  54. package/dist/SparklineChart.d.ts.map +1 -0
  55. package/dist/SparklineChart.js +35 -0
  56. package/dist/SparklineChart.js.map +1 -0
  57. package/dist/Text.d.ts +1 -1
  58. package/dist/Text.d.ts.map +1 -1
  59. package/dist/Text.js +2 -2
  60. package/dist/Text.js.map +1 -1
  61. package/dist/TextField.d.ts.map +1 -1
  62. package/dist/TextField.js +12 -4
  63. package/dist/TextField.js.map +1 -1
  64. package/dist/ToastNotifications.d.ts.map +1 -1
  65. package/dist/ToastNotifications.js +29 -6
  66. package/dist/ToastNotifications.js.map +1 -1
  67. package/dist/WebDropdownMenu.d.ts +2 -1
  68. package/dist/WebDropdownMenu.d.ts.map +1 -1
  69. package/dist/WebDropdownMenu.js +2 -6
  70. package/dist/WebDropdownMenu.js.map +1 -1
  71. package/dist/asks/AskCard.d.ts +34 -0
  72. package/dist/asks/AskCard.d.ts.map +1 -0
  73. package/dist/asks/AskCard.js +91 -0
  74. package/dist/asks/AskCard.js.map +1 -0
  75. package/dist/asks/AskChoice.d.ts +11 -0
  76. package/dist/asks/AskChoice.d.ts.map +1 -0
  77. package/dist/asks/AskChoice.js +146 -0
  78. package/dist/asks/AskChoice.js.map +1 -0
  79. package/dist/asks/AskConfirm.d.ts +15 -0
  80. package/dist/asks/AskConfirm.d.ts.map +1 -0
  81. package/dist/asks/AskConfirm.js +17 -0
  82. package/dist/asks/AskConfirm.js.map +1 -0
  83. package/dist/asks/AskFiles.d.ts +18 -0
  84. package/dist/asks/AskFiles.d.ts.map +1 -0
  85. package/dist/asks/AskFiles.js +149 -0
  86. package/dist/asks/AskFiles.js.map +1 -0
  87. package/dist/asks/AskForm.d.ts +27 -0
  88. package/dist/asks/AskForm.d.ts.map +1 -0
  89. package/dist/asks/AskForm.js +146 -0
  90. package/dist/asks/AskForm.js.map +1 -0
  91. package/dist/asks/AskMarkdown.d.ts +25 -0
  92. package/dist/asks/AskMarkdown.d.ts.map +1 -0
  93. package/dist/asks/AskMarkdown.js +73 -0
  94. package/dist/asks/AskMarkdown.js.map +1 -0
  95. package/dist/asks/SimpleAskCard.d.ts +23 -0
  96. package/dist/asks/SimpleAskCard.d.ts.map +1 -0
  97. package/dist/asks/SimpleAskCard.js +32 -0
  98. package/dist/asks/SimpleAskCard.js.map +1 -0
  99. package/dist/asks/askControls.d.ts +33 -0
  100. package/dist/asks/askControls.d.ts.map +1 -0
  101. package/dist/asks/askControls.js +30 -0
  102. package/dist/asks/askControls.js.map +1 -0
  103. package/dist/asks/askFileRefs.d.ts +26 -0
  104. package/dist/asks/askFileRefs.d.ts.map +1 -0
  105. package/dist/asks/askFileRefs.js +75 -0
  106. package/dist/asks/askFileRefs.js.map +1 -0
  107. package/dist/asks/askFormDraft.d.ts +60 -0
  108. package/dist/asks/askFormDraft.d.ts.map +1 -0
  109. package/dist/asks/askFormDraft.js +224 -0
  110. package/dist/asks/askFormDraft.js.map +1 -0
  111. package/dist/asks/askSummary.d.ts +10 -0
  112. package/dist/asks/askSummary.d.ts.map +1 -0
  113. package/dist/asks/askSummary.js +138 -0
  114. package/dist/asks/askSummary.js.map +1 -0
  115. package/dist/asks/askTypes.d.ts +21 -0
  116. package/dist/asks/askTypes.d.ts.map +1 -0
  117. package/dist/asks/askTypes.js +2 -0
  118. package/dist/asks/askTypes.js.map +1 -0
  119. package/dist/asks/simpleCardButtonVariants.d.ts +5 -0
  120. package/dist/asks/simpleCardButtonVariants.d.ts.map +1 -0
  121. package/dist/asks/simpleCardButtonVariants.js +8 -0
  122. package/dist/asks/simpleCardButtonVariants.js.map +1 -0
  123. package/dist/blocks/BlocksError.d.ts +8 -0
  124. package/dist/blocks/BlocksError.d.ts.map +1 -0
  125. package/dist/blocks/BlocksError.js +14 -0
  126. package/dist/blocks/BlocksError.js.map +1 -0
  127. package/dist/blocks/BlocksView.d.ts +10 -0
  128. package/dist/blocks/BlocksView.d.ts.map +1 -0
  129. package/dist/blocks/BlocksView.js +90 -0
  130. package/dist/blocks/BlocksView.js.map +1 -0
  131. package/dist/blocks/blockRenderers.d.ts +25 -0
  132. package/dist/blocks/blockRenderers.d.ts.map +1 -0
  133. package/dist/blocks/blockRenderers.js +136 -0
  134. package/dist/blocks/blockRenderers.js.map +1 -0
  135. package/dist/blocks/datasetToPoints.d.ts +22 -0
  136. package/dist/blocks/datasetToPoints.d.ts.map +1 -0
  137. package/dist/blocks/datasetToPoints.js +28 -0
  138. package/dist/blocks/datasetToPoints.js.map +1 -0
  139. package/dist/blocks/useBlockSelections.d.ts +6 -0
  140. package/dist/blocks/useBlockSelections.d.ts.map +1 -0
  141. package/dist/blocks/useBlockSelections.js +10 -0
  142. package/dist/blocks/useBlockSelections.js.map +1 -0
  143. package/dist/blocks/useResolvedDatasets.d.ts +18 -0
  144. package/dist/blocks/useResolvedDatasets.d.ts.map +1 -0
  145. package/dist/blocks/useResolvedDatasets.js +59 -0
  146. package/dist/blocks/useResolvedDatasets.js.map +1 -0
  147. package/dist/blocks/useResolvedImages.d.ts +15 -0
  148. package/dist/blocks/useResolvedImages.d.ts.map +1 -0
  149. package/dist/blocks/useResolvedImages.js +66 -0
  150. package/dist/blocks/useResolvedImages.js.map +1 -0
  151. package/dist/charts/ChartFacadeContainer.d.ts +10 -0
  152. package/dist/charts/ChartFacadeContainer.d.ts.map +1 -0
  153. package/dist/charts/ChartFacadeContainer.js +10 -0
  154. package/dist/charts/ChartFacadeContainer.js.map +1 -0
  155. package/dist/charts/ChartFrame.d.ts +4 -0
  156. package/dist/charts/ChartFrame.d.ts.map +1 -1
  157. package/dist/charts/ChartFrame.js +4 -2
  158. package/dist/charts/ChartFrame.js.map +1 -1
  159. package/dist/charts/layout.d.ts +9 -2
  160. package/dist/charts/layout.d.ts.map +1 -1
  161. package/dist/charts/layout.js +28 -6
  162. package/dist/charts/layout.js.map +1 -1
  163. package/dist/charts/scales.d.ts +3 -1
  164. package/dist/charts/scales.d.ts.map +1 -1
  165. package/dist/charts/scales.js +7 -7
  166. package/dist/charts/scales.js.map +1 -1
  167. package/dist/charts/series.d.ts +15 -0
  168. package/dist/charts/series.d.ts.map +1 -0
  169. package/dist/charts/series.js +19 -0
  170. package/dist/charts/series.js.map +1 -0
  171. package/dist/charts/types/chartTypes.d.ts +7 -0
  172. package/dist/charts/types/chartTypes.d.ts.map +1 -1
  173. package/dist/dashboardGridLayout.d.ts +6 -0
  174. package/dist/dashboardGridLayout.d.ts.map +1 -1
  175. package/dist/dashboardGridLayout.js +19 -3
  176. package/dist/dashboardGridLayout.js.map +1 -1
  177. package/dist/index.d.ts +9 -1
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +4 -1
  180. package/dist/index.js.map +1 -1
  181. package/dist/lazyBoundaries/heavyOptionalExports.d.ts +15 -0
  182. package/dist/lazyBoundaries/heavyOptionalExports.d.ts.map +1 -1
  183. package/dist/lazyBoundaries/heavyOptionalExports.js +10 -0
  184. package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -1
  185. package/dist/resolveDocumentBodyPortalTarget.d.ts +7 -0
  186. package/dist/resolveDocumentBodyPortalTarget.d.ts.map +1 -0
  187. package/dist/resolveDocumentBodyPortalTarget.js +12 -0
  188. package/dist/resolveDocumentBodyPortalTarget.js.map +1 -0
  189. package/package.json +2 -1
  190. package/src/AIRequestExplorer.test.tsx +2 -2
  191. package/src/AreaChart.test.tsx +81 -0
  192. package/src/AreaChart.tsx +171 -62
  193. package/src/BarChart.test.tsx +119 -0
  194. package/src/BarChart.tsx +94 -20
  195. package/src/Button.test.tsx +72 -0
  196. package/src/Button.tsx +34 -4
  197. package/src/ChartCard.test.tsx +79 -0
  198. package/src/ChartCard.tsx +80 -0
  199. package/src/Common.ts +136 -2
  200. package/src/DashboardGrid.test.tsx +98 -1
  201. package/src/DashboardGrid.tsx +71 -20
  202. package/src/DateTimeField.test.tsx +185 -2
  203. package/src/DateTimeField.tsx +106 -16
  204. package/src/DonutChart.test.tsx +78 -10
  205. package/src/DonutChart.tsx +87 -14
  206. package/src/DropdownMenuItem.tsx +48 -0
  207. package/src/FilePickerButton.test.tsx +116 -9
  208. package/src/FilePickerButton.tsx +177 -23
  209. package/src/GPTChat.test.tsx +891 -8
  210. package/src/GPTChat.tsx +713 -45
  211. package/src/HtmlFrame.tsx +60 -0
  212. package/src/LineChart.test.tsx +109 -10
  213. package/src/LineChart.tsx +154 -58
  214. package/src/Scorecard.test.tsx +65 -0
  215. package/src/Scorecard.tsx +45 -0
  216. package/src/SparklineChart.test.tsx +69 -0
  217. package/src/SparklineChart.tsx +85 -0
  218. package/src/Text.test.tsx +22 -0
  219. package/src/Text.tsx +10 -1
  220. package/src/TextField.test.tsx +16 -0
  221. package/src/TextField.tsx +13 -3
  222. package/src/ToastNotifications.tsx +33 -6
  223. package/src/ToastNotifications.webModal.test.tsx +285 -0
  224. package/src/WebDropdownMenu.tsx +3 -7
  225. package/src/asks/AskCard.test.tsx +1428 -0
  226. package/src/asks/AskCard.tsx +240 -0
  227. package/src/asks/AskChoice.tsx +368 -0
  228. package/src/asks/AskConfirm.tsx +42 -0
  229. package/src/asks/AskFiles.test.tsx +347 -0
  230. package/src/asks/AskFiles.tsx +246 -0
  231. package/src/asks/AskForm.tsx +334 -0
  232. package/src/asks/AskMarkdown.tsx +176 -0
  233. package/src/asks/SimpleAskCard.test.tsx +253 -0
  234. package/src/asks/SimpleAskCard.tsx +82 -0
  235. package/src/asks/askControls.tsx +98 -0
  236. package/src/asks/askFileRefs.test.ts +155 -0
  237. package/src/asks/askFileRefs.ts +98 -0
  238. package/src/asks/askFormDraft.test.ts +347 -0
  239. package/src/asks/askFormDraft.ts +309 -0
  240. package/src/asks/askSummary.test.ts +255 -0
  241. package/src/asks/askSummary.ts +160 -0
  242. package/src/asks/askTypes.ts +25 -0
  243. package/src/asks/asksUseTerrenoComponents.test.ts +55 -0
  244. package/src/asks/simpleCardButtonVariants.ts +14 -0
  245. package/src/blocks/BlocksError.tsx +28 -0
  246. package/src/blocks/BlocksView.test.tsx +607 -0
  247. package/src/blocks/BlocksView.tsx +125 -0
  248. package/src/blocks/blockRenderers.tsx +288 -0
  249. package/src/blocks/datasetToPoints.test.ts +31 -0
  250. package/src/blocks/datasetToPoints.ts +48 -0
  251. package/src/blocks/useBlockSelections.ts +13 -0
  252. package/src/blocks/useResolvedDatasets.ts +78 -0
  253. package/src/blocks/useResolvedImages.ts +81 -0
  254. package/src/bunSetup.ts +1 -0
  255. package/src/charts/ChartFacadeContainer.tsx +35 -0
  256. package/src/charts/ChartFrame.tsx +39 -1
  257. package/src/charts/layout.test.ts +22 -1
  258. package/src/charts/layout.ts +37 -4
  259. package/src/charts/scales.test.ts +33 -0
  260. package/src/charts/scales.ts +10 -6
  261. package/src/charts/series.ts +43 -0
  262. package/src/charts/types/chartTypes.ts +8 -0
  263. package/src/dashboardGridLayout.test.ts +59 -1
  264. package/src/dashboardGridLayout.ts +30 -3
  265. package/src/index.tsx +13 -0
  266. package/src/isolated/HtmlFrame.isolated.tsx +54 -0
  267. package/src/lazyBoundaries/heavyOptionalExports.test.tsx +2 -0
  268. package/src/lazyBoundaries/heavyOptionalExports.tsx +35 -0
  269. package/src/resolveDocumentBodyPortalTarget.ts +11 -0
@@ -0,0 +1,35 @@
1
+ import type {FC, ReactNode} from "react";
2
+
3
+ import {ChartCard} from "../ChartCard";
4
+ import {resolveTestID} from "../testing/resolveTestId";
5
+
6
+ export interface ChartFacadeContainerProps {
7
+ children: ReactNode;
8
+ onPeriodPress?: () => void;
9
+ periodLabel?: string;
10
+ testID?: string;
11
+ title?: string;
12
+ }
13
+
14
+ export const ChartFacadeContainer: FC<ChartFacadeContainerProps> = ({
15
+ children,
16
+ onPeriodPress,
17
+ periodLabel,
18
+ testID,
19
+ title,
20
+ }) => {
21
+ if (!title) {
22
+ return children;
23
+ }
24
+
25
+ return (
26
+ <ChartCard
27
+ onPeriodPress={onPeriodPress}
28
+ periodLabel={periodLabel}
29
+ testID={resolveTestID(testID, "card")}
30
+ title={title}
31
+ >
32
+ {children}
33
+ </ChartCard>
34
+ );
35
+ };
@@ -11,6 +11,7 @@ export interface ChartFrameProps {
11
11
  children: ReactNode;
12
12
  emptyText: string;
13
13
  isEmpty: boolean;
14
+ legendItems?: Array<{color: string; label: string}>;
14
15
  legendLabel?: string;
15
16
  loading?: boolean;
16
17
  testID?: string;
@@ -22,6 +23,7 @@ export const ChartFrame: FC<ChartFrameProps> = ({
22
23
  children,
23
24
  emptyText,
24
25
  isEmpty,
26
+ legendItems,
25
27
  legendLabel,
26
28
  loading = false,
27
29
  testID,
@@ -55,7 +57,43 @@ export const ChartFrame: FC<ChartFrameProps> = ({
55
57
  ) : null}
56
58
  </Box>
57
59
  ) : null}
58
- {showPlot && legendLabel ? (
60
+ {showPlot && legendItems && legendItems.length > 0 ? (
61
+ <Box
62
+ direction="row"
63
+ gap={3}
64
+ height={CHART_FOOTER_ROW_HEIGHT}
65
+ minWidth={0}
66
+ overflow="hidden"
67
+ >
68
+ {legendItems.map((item, index) => (
69
+ <Box
70
+ alignItems="center"
71
+ dangerouslySetInlineStyle={{__style: {flexBasis: 0, flexGrow: 1, flexShrink: 1}}}
72
+ direction="row"
73
+ gap={1}
74
+ key={`${item.label}-${index}`}
75
+ minWidth={0}
76
+ testID={resolveTestID(testID, `legend.${index}.item`)}
77
+ >
78
+ <Box
79
+ dangerouslySetInlineStyle={{
80
+ __style: {backgroundColor: item.color, height: 8, width: 8},
81
+ }}
82
+ testID={resolveTestID(testID, `legend.${index}.swatch`)}
83
+ />
84
+ <Text
85
+ size="sm"
86
+ skipLinking
87
+ testID={resolveTestID(testID, `legend.${index}`)}
88
+ truncate
89
+ >
90
+ {item.label}
91
+ </Text>
92
+ </Box>
93
+ ))}
94
+ </Box>
95
+ ) : null}
96
+ {showPlot && (!legendItems || legendItems.length === 0) && legendLabel ? (
59
97
  <Box height={CHART_FOOTER_ROW_HEIGHT} minWidth={0} overflow="hidden">
60
98
  <Text size="sm" skipLinking testID={resolveTestID(testID, "legend")} truncate>
61
99
  {legendLabel}
@@ -1,4 +1,5 @@
1
1
  import {describe, expect, it} from "bun:test";
2
+ import {assert} from "chai";
2
3
 
3
4
  import {
4
5
  CHART_Y_AXIS_MAX_WIDTH,
@@ -8,6 +9,7 @@ import {
8
9
  getPlotHeight,
9
10
  getXTickStyle,
10
11
  getYTickStyle,
12
+ shouldRotateChartXTicks,
11
13
  } from "./layout";
12
14
 
13
15
  describe("chart layout", () => {
@@ -19,8 +21,16 @@ describe("chart layout", () => {
19
21
  expect(getPlotHeight({hasLegend: true, height: 200})).toBe(146);
20
22
  });
21
23
 
24
+ it("reserves a custom x-axis height for rotated labels", () => {
25
+ assert.equal(getPlotHeight({hasLegend: false, height: 200, xAxisHeight: 72}), 110);
26
+ });
27
+
22
28
  it("keeps a drawable plot when the requested height is smaller than the rows", () => {
23
- expect(getPlotHeight({hasLegend: true, height: 20})).toBe(40);
29
+ expect(getPlotHeight({hasLegend: true, height: 20})).toBe(1);
30
+ });
31
+
32
+ it("keeps rotated charts inside the requested height", () => {
33
+ assert.equal(getPlotHeight({hasLegend: true, height: 140, xAxisHeight: 72}), 32);
24
34
  });
25
35
 
26
36
  it("fits a donut inside the height left by tooltip and padded, gapped legend rows", () => {
@@ -69,6 +79,17 @@ describe("chart layout", () => {
69
79
  expect(getXTickStyle({bandwidth: 0, xCenter: 10}).width).toBe(1);
70
80
  });
71
81
 
82
+ it("rotates dense auto ticks but respects explicit policies", () => {
83
+ assert.isFalse(shouldRotateChartXTicks({labelCount: 7, policy: "auto"}));
84
+ assert.isTrue(shouldRotateChartXTicks({labelCount: 8, policy: "auto"}));
85
+ assert.isTrue(shouldRotateChartXTicks({labelCount: 2, policy: "rotate"}));
86
+ assert.isFalse(shouldRotateChartXTicks({labelCount: 20, policy: "truncate"}));
87
+ assert.deepInclude(getXTickStyle({bandwidth: 10, isRotated: true, xCenter: 20}), {
88
+ transform: [{rotate: "45deg"}],
89
+ transformOrigin: "left top",
90
+ });
91
+ });
92
+
72
93
  it("centers a y tick label on its value and spans the axis gutter", () => {
73
94
  expect(getYTickStyle({axisWidth: 40, y: 50})).toEqual({
74
95
  left: 0,
@@ -2,6 +2,7 @@ import type {ChartPlot} from "./types/chartTypes";
2
2
 
3
3
  export const CHART_Y_AXIS_MAX_WIDTH = 40;
4
4
  export const CHART_X_AXIS_HEIGHT = 18;
5
+ export const CHART_ROTATED_X_AXIS_HEIGHT = 72;
5
6
  export const CHART_FOOTER_ROW_HEIGHT = 18;
6
7
 
7
8
  const Y_AXIS_WIDTH_RATIO = 0.3;
@@ -39,12 +40,18 @@ export const getChartAxisWidth = (chartWidth: number): number => {
39
40
  export const getPlotHeight = ({
40
41
  hasLegend,
41
42
  height,
43
+ xAxisHeight = CHART_X_AXIS_HEIGHT,
42
44
  }: {
43
45
  hasLegend: boolean;
44
46
  height: number;
47
+ xAxisHeight?: number;
45
48
  }): number => {
46
- const footer = CHART_X_AXIS_HEIGHT + CHART_FOOTER_ROW_HEIGHT * (hasLegend ? 2 : 1);
47
- return Math.max(height - footer, MIN_PLOT_HEIGHT);
49
+ const footer = xAxisHeight + CHART_FOOTER_ROW_HEIGHT * (hasLegend ? 2 : 1);
50
+ const remaining = height - footer;
51
+ if (remaining >= MIN_PLOT_HEIGHT) {
52
+ return remaining;
53
+ }
54
+ return Math.max(remaining, 1);
48
55
  };
49
56
 
50
57
  export const getDonutSize = ({
@@ -85,13 +92,39 @@ export const getChartPlot = ({
85
92
  */
86
93
  export const getXTickStyle = ({
87
94
  bandwidth,
95
+ isRotated = false,
88
96
  xCenter,
89
97
  }: {
90
98
  bandwidth: number;
99
+ isRotated?: boolean;
91
100
  xCenter: number;
92
101
  }): ChartTickStyle => {
93
- const width = Math.max(bandwidth, 1);
94
- return {left: xCenter - width / 2, position: "absolute", top: 0, width};
102
+ const width = isRotated
103
+ ? Math.max(bandwidth * 1.5, CHART_ROTATED_X_AXIS_HEIGHT)
104
+ : Math.max(bandwidth, 1);
105
+ return {
106
+ left: isRotated ? xCenter - bandwidth / 4 : xCenter - width / 2,
107
+ position: "absolute",
108
+ top: 0,
109
+ ...(isRotated ? {transform: [{rotate: "45deg"}], transformOrigin: "left top"} : {}),
110
+ width,
111
+ };
112
+ };
113
+
114
+ export const shouldRotateChartXTicks = ({
115
+ labelCount,
116
+ policy = "auto",
117
+ }: {
118
+ labelCount: number;
119
+ policy?: "auto" | "rotate" | "truncate";
120
+ }): boolean => {
121
+ if (policy === "rotate") {
122
+ return true;
123
+ }
124
+ if (policy === "truncate") {
125
+ return false;
126
+ }
127
+ return labelCount > 7;
95
128
  };
96
129
 
97
130
  export const getYTickStyle = ({axisWidth, y}: {axisWidth: number; y: number}): ChartTickStyle => {
@@ -1,4 +1,5 @@
1
1
  import {describe, expect, it} from "bun:test";
2
+ import {assert} from "chai";
2
3
 
3
4
  import {createCartesianScales, getYTickValues} from "./scales";
4
5
  import type {ChartPoint} from "./types/chartTypes";
@@ -27,6 +28,38 @@ describe("createCartesianScales", () => {
27
28
  expect(scales.y(50)).toBe(50);
28
29
  });
29
30
 
31
+ it("scales a sparkline to the data range instead of forcing zero", () => {
32
+ const points = [
33
+ {label: "A", value: 100},
34
+ {label: "B", value: 110},
35
+ ];
36
+ const scales = createCartesianScales({
37
+ includeZero: false,
38
+ plot: PLOT,
39
+ points,
40
+ });
41
+
42
+ assert.equal(scales.y(100), 100);
43
+ assert.equal(scales.y(110), 0);
44
+ });
45
+
46
+ it("uses the explicit shared x labels while scaling all series values on y", () => {
47
+ const points = [
48
+ ...FIXTURE_POINTS,
49
+ ...FIXTURE_POINTS.map((point) => ({...point, value: point.value / 2})),
50
+ ];
51
+ const scales = createCartesianScales({
52
+ plot: PLOT,
53
+ points,
54
+ xLabels: FIXTURE_POINTS.map((point) => point.label),
55
+ });
56
+
57
+ assert.equal(scales.bandwidth, 30);
58
+ assert.equal(scales.xCenter("C"), 85);
59
+ assert.equal(scales.y(100), 0);
60
+ assert.equal(scales.y(25), 75);
61
+ });
62
+
30
63
  it("returns three ticks from the y domain including zero", () => {
31
64
  expect(getYTickValues(FIXTURE_POINTS)).toEqual([0, 50, 100]);
32
65
  });
@@ -4,14 +4,14 @@ import type {ChartPlot, ChartPoint, ChartScales} from "./types/chartTypes";
4
4
 
5
5
  const EMPTY_Y_DOMAIN: [number, number] = [0, 1];
6
6
 
7
- const getYDomain = (points: ChartPoint[]): [number, number] => {
7
+ const getYDomain = (points: ChartPoint[], includeZero: boolean): [number, number] => {
8
8
  if (points.length === 0) {
9
9
  return EMPTY_Y_DOMAIN;
10
10
  }
11
11
 
12
12
  const values = points.map((point) => point.value);
13
- const min = Math.min(0, ...values);
14
- const max = Math.max(0, ...values);
13
+ const min = includeZero ? Math.min(0, ...values) : Math.min(...values);
14
+ const max = includeZero ? Math.max(0, ...values) : Math.max(...values);
15
15
  if (min === max) {
16
16
  return [min, min + 1];
17
17
  }
@@ -24,24 +24,28 @@ export const getYTickValues = (points: ChartPoint[]): number[] => {
24
24
  return [];
25
25
  }
26
26
 
27
- const [min, max] = getYDomain(points);
27
+ const [min, max] = getYDomain(points, true);
28
28
  const mid = min + (max - min) / 2;
29
29
  return [min, mid, max];
30
30
  };
31
31
 
32
32
  export const createCartesianScales = ({
33
+ includeZero = true,
33
34
  plot,
34
35
  points,
36
+ xLabels,
35
37
  }: {
38
+ includeZero?: boolean;
36
39
  plot: ChartPlot;
37
40
  points: ChartPoint[];
41
+ xLabels?: string[];
38
42
  }): ChartScales => {
39
43
  const bottom = plot.top + plot.height;
40
- const labels = points.map((point) => point.label);
44
+ const labels = xLabels ?? points.map((point) => point.label);
41
45
  const xScale = scaleBand<string>()
42
46
  .domain(labels)
43
47
  .range([plot.left, plot.left + plot.width]);
44
- const yScale = scaleLinear().domain(getYDomain(points)).range([bottom, plot.top]);
48
+ const yScale = scaleLinear().domain(getYDomain(points, includeZero)).range([bottom, plot.top]);
45
49
  const bandwidth = labels.length === 0 ? 0 : xScale.bandwidth();
46
50
 
47
51
  const xStart = (label: string): number => {
@@ -0,0 +1,43 @@
1
+ import type {ChartPoint, ChartSeries} from "./types/chartTypes";
2
+
3
+ export const resolveChartSeries = ({
4
+ data,
5
+ legendLabel,
6
+ series,
7
+ }: {
8
+ data: ChartPoint[];
9
+ legendLabel?: string;
10
+ series?: ChartSeries[];
11
+ }): ChartSeries[] => {
12
+ if (series && series.length > 0) {
13
+ return series;
14
+ }
15
+
16
+ return [{data, id: "default", label: legendLabel ?? ""}];
17
+ };
18
+
19
+ export const getAllSeriesPoints = ({
20
+ comparisonData = [],
21
+ series,
22
+ }: {
23
+ comparisonData?: ChartPoint[];
24
+ series: ChartSeries[];
25
+ }): ChartPoint[] => {
26
+ return [...series.flatMap((entry) => entry.data), ...comparisonData];
27
+ };
28
+
29
+ export const getAxisPoints = ({
30
+ comparisonData = [],
31
+ series,
32
+ }: {
33
+ comparisonData?: ChartPoint[];
34
+ series: ChartSeries[];
35
+ }): ChartPoint[] => {
36
+ const pointsByLabel = new Map<string, ChartPoint>();
37
+ for (const point of getAllSeriesPoints({comparisonData, series})) {
38
+ if (!pointsByLabel.has(point.label)) {
39
+ pointsByLabel.set(point.label, point);
40
+ }
41
+ }
42
+ return [...pointsByLabel.values()];
43
+ };
@@ -4,6 +4,14 @@ export interface ChartPoint {
4
4
  value: number;
5
5
  }
6
6
 
7
+ export interface ChartSeries {
8
+ color?: string;
9
+ data: ChartPoint[];
10
+ id: string;
11
+ label: string;
12
+ stroke?: "solid" | "dotted";
13
+ }
14
+
7
15
  export interface ChartPlot {
8
16
  height: number;
9
17
  left: number;
@@ -1,7 +1,12 @@
1
1
  import {afterEach, describe, expect, it} from "bun:test";
2
+ import {assert} from "chai";
2
3
  import {Platform} from "react-native";
3
4
 
4
- import {getDashboardCellBoxStyle, getDashboardCellWidth} from "./dashboardGridLayout";
5
+ import {
6
+ getDashboardCellBoxStyle,
7
+ getDashboardCellWidth,
8
+ getDashboardSpanCellBoxStyle,
9
+ } from "./dashboardGridLayout";
5
10
 
6
11
  const originalOS = Platform.OS;
7
12
 
@@ -64,6 +69,59 @@ describe("getDashboardCellBoxStyle", () => {
64
69
  ).toBe("calc((100% - 32px) / 3)");
65
70
  });
66
71
 
72
+ it("adds the internal gap when a measured cell spans two columns", () => {
73
+ assert.deepInclude(
74
+ getDashboardSpanCellBoxStyle({
75
+ columnCount: 4,
76
+ gapPx: 16,
77
+ rowWidth: 332,
78
+ span: 2,
79
+ }),
80
+ {width: 156}
81
+ );
82
+ });
83
+
84
+ it("clamps measured spans to the available columns", () => {
85
+ const fullSpan = getDashboardSpanCellBoxStyle({
86
+ columnCount: 4,
87
+ gapPx: 16,
88
+ rowWidth: 332,
89
+ span: 8,
90
+ });
91
+ assert.equal(fullSpan.width, 328);
92
+
93
+ const minimumSpan = getDashboardSpanCellBoxStyle({
94
+ columnCount: 4,
95
+ gapPx: 16,
96
+ rowWidth: 332,
97
+ span: 0,
98
+ });
99
+ assert.equal(minimumSpan.width, 70);
100
+ });
101
+
102
+ it("uses responsive web calc widths before measurement", () => {
103
+ Platform.OS = "web";
104
+
105
+ assert.equal(
106
+ getDashboardSpanCellBoxStyle({
107
+ columnCount: 4,
108
+ gapPx: 16,
109
+ rowWidth: 0,
110
+ span: 2,
111
+ }).width,
112
+ "calc(((100% - 48px) / 4) * 2 + 16px)"
113
+ );
114
+ assert.equal(
115
+ getDashboardSpanCellBoxStyle({
116
+ columnCount: 4,
117
+ gapPx: 16,
118
+ rowWidth: 0,
119
+ span: 4,
120
+ }).width,
121
+ "100%"
122
+ );
123
+ });
124
+
67
125
  it("falls back to a full-width cell on native, which has no calc", () => {
68
126
  Platform.OS = "ios";
69
127
 
@@ -47,14 +47,41 @@ export const getDashboardCellBoxStyle = ({
47
47
  gapPx: number;
48
48
  rowWidth: number;
49
49
  }): DashboardCellStyle => {
50
+ return getDashboardSpanCellBoxStyle({columnCount, gapPx, rowWidth, span: 1});
51
+ };
52
+
53
+ export const getDashboardSpanCellBoxStyle = ({
54
+ columnCount,
55
+ gapPx,
56
+ rowWidth,
57
+ span,
58
+ }: {
59
+ columnCount: number;
60
+ gapPx: number;
61
+ rowWidth: number;
62
+ span: number;
63
+ }): DashboardCellStyle => {
64
+ const safeColumnCount = Math.max(columnCount, 1);
65
+ const safeSpan = Math.min(Math.max(Math.floor(span), 1), safeColumnCount);
50
66
  if (rowWidth > 0) {
51
- const width = getDashboardCellWidth({columnCount, gapPx, rowWidth});
67
+ const baseWidth = getDashboardCellWidth({
68
+ columnCount: safeColumnCount,
69
+ gapPx,
70
+ rowWidth,
71
+ });
72
+ const width = baseWidth * safeSpan + gapPx * (safeSpan - 1);
52
73
  return {flexGrow: 0, flexShrink: 0, maxWidth: width, width};
53
74
  }
54
- if (columnCount <= 1 || Platform.OS !== "web") {
75
+ if (safeSpan === safeColumnCount || Platform.OS !== "web") {
55
76
  return {flexGrow: 0, flexShrink: 0, maxWidth: "100%", width: "100%"};
56
77
  }
57
78
 
58
- const width = `calc((100% - ${gapPx * (columnCount - 1)}px) / ${columnCount})`;
79
+ const gapTotal = gapPx * (safeColumnCount - 1);
80
+ if (safeSpan === 1) {
81
+ const width = `calc((100% - ${gapTotal}px) / ${safeColumnCount})`;
82
+ return {flexGrow: 0, flexShrink: 0, maxWidth: width, width};
83
+ }
84
+ const internalGaps = gapPx * (safeSpan - 1);
85
+ const width = `calc(((100% - ${gapTotal}px) / ${safeColumnCount}) * ${safeSpan} + ${internalGaps}px)`;
59
86
  return {flexGrow: 0, flexShrink: 0, maxWidth: width, width};
60
87
  };
package/src/index.tsx CHANGED
@@ -14,6 +14,10 @@ export * from "./AnnouncementScreen";
14
14
  export type * from "./AreaChart";
15
15
  export type * from "./AttachmentPreview";
16
16
  export * from "./Avatar";
17
+ export type * from "./asks/AskCard";
18
+ export * from "./asks/askFileRefs";
19
+ export type * from "./asks/askTypes";
20
+ export * from "./asks/SimpleAskCard";
17
21
  export * from "./Badge";
18
22
  export {Banner, hideBanner} from "./Banner";
19
23
  export type * from "./BarChart";
@@ -22,6 +26,7 @@ export * from "./BooleanField";
22
26
  export * from "./Box";
23
27
  export * from "./Button";
24
28
  export * from "./Card";
29
+ export type * from "./ChartCard";
25
30
  export * from "./CheckBox";
26
31
  export * from "./Common";
27
32
  export type * from "./ConflictSheet";
@@ -57,6 +62,7 @@ export type * from "./GPTMemoryModal";
57
62
  export * from "./Heading";
58
63
  export * from "./HeightActionSheet";
59
64
  export * from "./HeightField";
65
+ export * from "./HtmlFrame";
60
66
  export * from "./Icon";
61
67
  export * from "./IconButton";
62
68
  export * from "./IconRegistry";
@@ -71,8 +77,11 @@ export {
71
77
  AIRequestExplorer,
72
78
  AiSuggestionBox,
73
79
  AreaChart,
80
+ AskCard,
74
81
  AttachmentPreview,
75
82
  BarChart,
83
+ BlocksView,
84
+ ChartCard,
76
85
  ConflictSheet,
77
86
  ConsentFormScreen,
78
87
  ConsentNavigator,
@@ -84,6 +93,8 @@ export {
84
93
  LineChart,
85
94
  MarkdownEditor,
86
95
  MarkdownEditorField,
96
+ Scorecard,
97
+ SparklineChart,
87
98
  UpgradeRequiredScreen,
88
99
  } from "./lazyBoundaries/heavyOptionalExports";
89
100
  export * from "./login/LoginScreen";
@@ -112,6 +123,7 @@ export * from "./PortalHost";
112
123
  export * from "./pdfHtmlTemplate";
113
124
  export * from "./Radio";
114
125
  export * from "./RadioField";
126
+ export type * from "./Scorecard";
115
127
  export * from "./ScrollView";
116
128
  export * from "./SectionDivider";
117
129
  export * from "./SegmentedControl";
@@ -124,6 +136,7 @@ export * from "./SignatureCaptureField";
124
136
  export * from "./SignatureField";
125
137
  export * from "./Slider";
126
138
  export * from "./SocialLoginButton";
139
+ export type * from "./SparklineChart";
127
140
  export * from "./Spinner";
128
141
  export * from "./SplitPage";
129
142
  export * from "./SyncStatusBanner";
@@ -0,0 +1,54 @@
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import {Platform, View} from "react-native";
3
+
4
+ import {HtmlFrame, htmlFrameSrcDoc} from "../HtmlFrame";
5
+ import {renderWithTheme} from "../test-utils";
6
+
7
+ mock.module("react-native-webview", () => ({
8
+ default: ({
9
+ javaScriptEnabled,
10
+ onShouldStartLoadWithRequest,
11
+ source,
12
+ }: {
13
+ javaScriptEnabled?: boolean;
14
+ onShouldStartLoadWithRequest?: (request: {url: string}) => boolean;
15
+ source?: {html?: string};
16
+ }) => {
17
+ const first = onShouldStartLoadWithRequest?.({url: "about:srcdoc"});
18
+ const second = onShouldStartLoadWithRequest?.({url: "https://evil.test"});
19
+ const startsWithCsp = String(source?.html ?? "").startsWith(
20
+ '<meta http-equiv="Content-Security-Policy"'
21
+ );
22
+ return (
23
+ <View
24
+ accessibilityLabel={`js:${String(javaScriptEnabled)};csp:${String(startsWithCsp)};first:${String(first)};second:${String(second)}`}
25
+ testID="html-frame-webview"
26
+ />
27
+ );
28
+ },
29
+ }));
30
+
31
+ describe("HtmlFrame", () => {
32
+ const originalOS = Platform.OS;
33
+
34
+ it("starts the web srcdoc with the CSP meta tag inside an empty sandbox", () => {
35
+ Platform.OS = "web";
36
+ const result = renderWithTheme(<HtmlFrame html="<h1>Invoice</h1>" title="Invoice preview" />);
37
+ const rendered = JSON.stringify(result.toJSON());
38
+ const srcDoc = htmlFrameSrcDoc("<h1>Invoice</h1>");
39
+ expect(result.getByTestId("html-frame-web")).toBeTruthy();
40
+ expect(rendered).toContain('sandbox":""');
41
+ expect(rendered).toContain(JSON.stringify(srcDoc).slice(1, -1));
42
+ expect(rendered.indexOf("Content-Security-Policy")).toBeLessThan(
43
+ rendered.indexOf("<h1>Invoice")
44
+ );
45
+ Platform.OS = originalOS;
46
+ });
47
+
48
+ it("turns JavaScript off and blocks navigation after the first load", () => {
49
+ Platform.OS = "ios";
50
+ const result = renderWithTheme(<HtmlFrame html="<p>Invoice</p>" />);
51
+ expect(result.getByLabelText("js:false;csp:true;first:true;second:false")).toBeTruthy();
52
+ Platform.OS = originalOS;
53
+ });
54
+ });
@@ -3,6 +3,7 @@ import {describe, expect, it} from "bun:test";
3
3
  import {Categories} from "../emojiCategories";
4
4
  import {
5
5
  AIRequestExplorer,
6
+ AskCard,
6
7
  DraggableList,
7
8
  EmojiSelector,
8
9
  heavyOptionalModuleFactories,
@@ -12,6 +13,7 @@ import {
12
13
  describe("heavyOptionalExports", () => {
13
14
  it("exposes lazy placeholders for heavy optional widgets", () => {
14
15
  expect(AIRequestExplorer).toBeTruthy();
16
+ expect(AskCard).toBeTruthy();
15
17
  expect(DraggableList).toBeTruthy();
16
18
  expect(EmojiSelector).toBeTruthy();
17
19
  expect(MarkdownEditor).toBeTruthy();