@terreno/ui 57.3.0 → 57.4.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 (212) hide show
  1. package/dist/AnnouncementBanner.d.ts +12 -0
  2. package/dist/AnnouncementBanner.js +61 -0
  3. package/dist/AnnouncementBanner.js.map +1 -0
  4. package/dist/AnnouncementNavigator.d.ts +11 -0
  5. package/dist/AnnouncementNavigator.js +189 -0
  6. package/dist/AnnouncementNavigator.js.map +1 -0
  7. package/dist/AnnouncementScreen.d.ts +12 -0
  8. package/dist/AnnouncementScreen.js +28 -0
  9. package/dist/AnnouncementScreen.js.map +1 -0
  10. package/dist/AreaChart.d.ts +5 -0
  11. package/dist/AreaChart.js +69 -0
  12. package/dist/AreaChart.js.map +1 -0
  13. package/dist/BarChart.d.ts +5 -0
  14. package/dist/BarChart.js +89 -0
  15. package/dist/BarChart.js.map +1 -0
  16. package/dist/Button.js +17 -3
  17. package/dist/Button.js.map +1 -1
  18. package/dist/Common.d.ts +96 -0
  19. package/dist/Common.js.map +1 -1
  20. package/dist/DashboardGrid.d.ts +4 -0
  21. package/dist/DashboardGrid.js +38 -0
  22. package/dist/DashboardGrid.js.map +1 -0
  23. package/dist/DataTable.js +83 -11
  24. package/dist/DataTable.js.map +1 -1
  25. package/dist/DonutChart.d.ts +5 -0
  26. package/dist/DonutChart.js +84 -0
  27. package/dist/DonutChart.js.map +1 -0
  28. package/dist/Filter.js +12 -2
  29. package/dist/Filter.js.map +1 -1
  30. package/dist/GPTChat.d.ts +7 -1
  31. package/dist/GPTChat.js +28 -15
  32. package/dist/GPTChat.js.map +1 -1
  33. package/dist/LineChart.d.ts +5 -0
  34. package/dist/LineChart.js +68 -0
  35. package/dist/LineChart.js.map +1 -0
  36. package/dist/MarkdownEmbed.d.ts +6 -0
  37. package/dist/MarkdownEmbed.js +17 -0
  38. package/dist/MarkdownEmbed.js.map +1 -0
  39. package/dist/MarkdownView.js +38 -3
  40. package/dist/MarkdownView.js.map +1 -1
  41. package/dist/Modal.js +12 -10
  42. package/dist/Modal.js.map +1 -1
  43. package/dist/ModalSheet.d.ts +5 -1
  44. package/dist/ModalSheet.js +31 -13
  45. package/dist/ModalSheet.js.map +1 -1
  46. package/dist/MultiselectField.js +4 -9
  47. package/dist/MultiselectField.js.map +1 -1
  48. package/dist/NotificationBell.d.ts +16 -0
  49. package/dist/NotificationBell.js +15 -0
  50. package/dist/NotificationBell.js.map +1 -0
  51. package/dist/NotificationInbox.d.ts +21 -0
  52. package/dist/NotificationInbox.js +41 -0
  53. package/dist/NotificationInbox.js.map +1 -0
  54. package/dist/NotificationPreferences.d.ts +14 -0
  55. package/dist/NotificationPreferences.js +32 -0
  56. package/dist/NotificationPreferences.js.map +1 -0
  57. package/dist/TextField.js +83 -6
  58. package/dist/TextField.js.map +1 -1
  59. package/dist/announcementBuildVersion.d.ts +6 -0
  60. package/dist/announcementBuildVersion.js +21 -0
  61. package/dist/announcementBuildVersion.js.map +1 -0
  62. package/dist/announcementFrequency.d.ts +42 -0
  63. package/dist/announcementFrequency.js +163 -0
  64. package/dist/announcementFrequency.js.map +1 -0
  65. package/dist/announcementPlatform.d.ts +2 -0
  66. package/dist/announcementPlatform.js +11 -0
  67. package/dist/announcementPlatform.js.map +1 -0
  68. package/dist/charts/ChartFrame.d.ts +12 -0
  69. package/dist/charts/ChartFrame.js +13 -0
  70. package/dist/charts/ChartFrame.js.map +1 -0
  71. package/dist/charts/bars.d.ts +18 -0
  72. package/dist/charts/bars.js +29 -0
  73. package/dist/charts/bars.js.map +1 -0
  74. package/dist/charts/layout.d.ts +47 -0
  75. package/dist/charts/layout.js +56 -0
  76. package/dist/charts/layout.js.map +1 -0
  77. package/dist/charts/paths.d.ts +31 -0
  78. package/dist/charts/paths.js +52 -0
  79. package/dist/charts/paths.js.map +1 -0
  80. package/dist/charts/scales.d.ts +6 -0
  81. package/dist/charts/scales.js +43 -0
  82. package/dist/charts/scales.js.map +1 -0
  83. package/dist/charts/theme.d.ts +9 -0
  84. package/dist/charts/theme.js +15 -0
  85. package/dist/charts/theme.js.map +1 -0
  86. package/dist/charts/types/chartTypes.d.ts +17 -0
  87. package/dist/charts/types/chartTypes.js +2 -0
  88. package/dist/charts/types/chartTypes.js.map +1 -0
  89. package/dist/dashboardGridLayout.d.ts +22 -0
  90. package/dist/dashboardGridLayout.js +33 -0
  91. package/dist/dashboardGridLayout.js.map +1 -0
  92. package/dist/dataTableFilters.d.ts +33 -0
  93. package/dist/dataTableFilters.js +221 -0
  94. package/dist/dataTableFilters.js.map +1 -0
  95. package/dist/dataTableListQuery.d.ts +42 -0
  96. package/dist/dataTableListQuery.js +161 -0
  97. package/dist/dataTableListQuery.js.map +1 -0
  98. package/dist/index.d.ts +18 -1
  99. package/dist/index.js +11 -1
  100. package/dist/index.js.map +1 -1
  101. package/dist/lazyBoundaries/heavyOptionalExports.d.ts +12 -0
  102. package/dist/lazyBoundaries/heavyOptionalExports.js +8 -0
  103. package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -1
  104. package/dist/markdownEmbeds.d.ts +6 -0
  105. package/dist/markdownEmbeds.js +59 -0
  106. package/dist/markdownEmbeds.js.map +1 -0
  107. package/dist/testing/resolveTestId.js +2 -1
  108. package/dist/testing/resolveTestId.js.map +1 -1
  109. package/dist/testing/types.d.ts +3 -0
  110. package/dist/textFieldOscillationGuard.d.ts +25 -0
  111. package/dist/textFieldOscillationGuard.js +41 -0
  112. package/dist/textFieldOscillationGuard.js.map +1 -0
  113. package/dist/useAcknowledgeAnnouncement.d.ts +71 -0
  114. package/dist/useAcknowledgeAnnouncement.js +94 -0
  115. package/dist/useAcknowledgeAnnouncement.js.map +1 -0
  116. package/dist/useAnnouncements.d.ts +73 -0
  117. package/dist/useAnnouncements.js +66 -0
  118. package/dist/useAnnouncements.js.map +1 -0
  119. package/package.json +7 -18
  120. package/src/AnnouncementBanner.test.tsx +267 -0
  121. package/src/AnnouncementBanner.tsx +128 -0
  122. package/src/AnnouncementNavigator.test.tsx +759 -0
  123. package/src/AnnouncementNavigator.tsx +287 -0
  124. package/src/AnnouncementScreen.test.tsx +97 -0
  125. package/src/AnnouncementScreen.tsx +70 -0
  126. package/src/AreaChart.test.tsx +68 -0
  127. package/src/AreaChart.tsx +194 -0
  128. package/src/BarChart.test.tsx +96 -0
  129. package/src/BarChart.tsx +208 -0
  130. package/src/Button.test.tsx +66 -0
  131. package/src/Button.tsx +17 -2
  132. package/src/Common.ts +95 -0
  133. package/src/ConsentNavigator.test.tsx +55 -0
  134. package/src/DashboardGrid.test.tsx +75 -0
  135. package/src/DashboardGrid.tsx +69 -0
  136. package/src/DataTable.test.tsx +296 -1
  137. package/src/DataTable.tsx +210 -18
  138. package/src/DonutChart.test.tsx +121 -0
  139. package/src/DonutChart.tsx +160 -0
  140. package/src/EmojiSelector.test.tsx +51 -0
  141. package/src/Field.test.tsx +18 -0
  142. package/src/Filter.test.tsx +25 -0
  143. package/src/Filter.tsx +38 -7
  144. package/src/GPTChat.test.tsx +107 -0
  145. package/src/GPTChat.tsx +176 -86
  146. package/src/LineChart.test.tsx +166 -0
  147. package/src/LineChart.tsx +190 -0
  148. package/src/MarkdownEmbed.test.tsx +34 -0
  149. package/src/MarkdownEmbed.tsx +43 -0
  150. package/src/MarkdownView.test.tsx +59 -2
  151. package/src/MarkdownView.tsx +51 -3
  152. package/src/Modal.test.tsx +107 -14
  153. package/src/Modal.tsx +20 -8
  154. package/src/ModalSheet.test.tsx +121 -9
  155. package/src/ModalSheet.tsx +46 -11
  156. package/src/MultiselectField.test.tsx +21 -0
  157. package/src/MultiselectField.tsx +11 -13
  158. package/src/NotificationBell.test.tsx +91 -0
  159. package/src/NotificationBell.tsx +77 -0
  160. package/src/NotificationInbox.test.tsx +130 -0
  161. package/src/NotificationInbox.tsx +144 -0
  162. package/src/NotificationPreferences.test.tsx +25 -0
  163. package/src/NotificationPreferences.tsx +75 -0
  164. package/src/RootImportRegression.test.tsx +20 -0
  165. package/src/TextField.test.tsx +421 -0
  166. package/src/TextField.tsx +121 -4
  167. package/src/__snapshots__/Field.test.tsx.snap +22 -0
  168. package/src/__snapshots__/ModalSheet.test.tsx.snap +4 -1
  169. package/src/__snapshots__/TextArea.test.tsx.snap +5 -5
  170. package/src/__snapshots__/TextField.test.tsx.snap +5 -5
  171. package/src/announcementBuildVersion.test.ts +43 -0
  172. package/src/announcementBuildVersion.ts +21 -0
  173. package/src/announcementFrequency.test.ts +245 -0
  174. package/src/announcementFrequency.ts +246 -0
  175. package/src/announcementPlatform.test.ts +27 -0
  176. package/src/announcementPlatform.ts +13 -0
  177. package/src/charts/ChartFrame.tsx +67 -0
  178. package/src/charts/bars.test.ts +56 -0
  179. package/src/charts/bars.ts +53 -0
  180. package/src/charts/layout.test.ts +80 -0
  181. package/src/charts/layout.ts +99 -0
  182. package/src/charts/paths.test.ts +79 -0
  183. package/src/charts/paths.ts +100 -0
  184. package/src/charts/scales.test.ts +59 -0
  185. package/src/charts/scales.ts +60 -0
  186. package/src/charts/theme.test.ts +22 -0
  187. package/src/charts/theme.ts +24 -0
  188. package/src/charts/types/chartTypes.ts +19 -0
  189. package/src/dashboardGridLayout.test.ts +90 -0
  190. package/src/dashboardGridLayout.ts +60 -0
  191. package/src/dataTableFilters.test.tsx +552 -0
  192. package/src/dataTableFilters.tsx +441 -0
  193. package/src/dataTableListQuery.test.ts +220 -0
  194. package/src/dataTableListQuery.ts +201 -0
  195. package/src/index.tsx +21 -1
  196. package/src/lazyBoundaries/heavyOptionalExports.tsx +28 -0
  197. package/src/login/__snapshots__/LoginScreen.test.tsx.snap +22 -0
  198. package/src/markdownEmbeds.test.ts +53 -0
  199. package/src/markdownEmbeds.ts +62 -0
  200. package/src/pdfHtmlTemplate.test.ts +119 -0
  201. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +22 -0
  202. package/src/testing/resolveTestId.test.ts +3 -0
  203. package/src/testing/resolveTestId.ts +1 -0
  204. package/src/testing/types.ts +3 -0
  205. package/src/textFieldOscillationGuard.test.ts +63 -0
  206. package/src/textFieldOscillationGuard.ts +89 -0
  207. package/src/types/react-native-markdown-display.d.ts +6 -0
  208. package/src/types/react-native-swiper-flatlist.d.ts +5 -5
  209. package/src/useAcknowledgeAnnouncement.test.ts +223 -0
  210. package/src/useAcknowledgeAnnouncement.ts +166 -0
  211. package/src/useAnnouncements.test.ts +226 -0
  212. package/src/useAnnouncements.ts +150 -0
@@ -0,0 +1,201 @@
1
+ import {DateTime} from "luxon";
2
+
3
+ import type {DataTableColumn, DataTableColumnFilter, DataTableQueryParams} from "./Common";
4
+
5
+ /** Debounce delay for DataTable toolbar search before emitting query params. */
6
+ export const DATA_TABLE_SEARCH_DEBOUNCE_MS = 250;
7
+
8
+ /**
9
+ * Wire-format sentinel for optional choice filters meaning "field is null or unset".
10
+ * Must match `ADMIN_LIST_CHOICE_EMPTY_VALUE` in `@terreno/api`.
11
+ */
12
+ export const DATA_TABLE_CHOICE_EMPTY_VALUE = "__empty__";
13
+
14
+ export const DATA_TABLE_CHOICE_EMPTY_LABEL = "Empty";
15
+
16
+ /**
17
+ * Date range bounds are collected as calendar days, so the range covers whole UTC days:
18
+ * the lower bound opens the chosen day and the upper bound closes it. Without this the
19
+ * upper bound would land on midnight and exclude everything recorded later that day.
20
+ */
21
+ export const startOfUtcDay = (isoValue: string): string => {
22
+ const parsed = DateTime.fromISO(isoValue, {zone: "utc"});
23
+ if (!parsed.isValid) {
24
+ return isoValue;
25
+ }
26
+ return parsed.startOf("day").toISO({suppressMilliseconds: false}) ?? isoValue;
27
+ };
28
+
29
+ export const endOfUtcDay = (isoValue: string): string => {
30
+ const parsed = DateTime.fromISO(isoValue, {zone: "utc"});
31
+ if (!parsed.isValid) {
32
+ return isoValue;
33
+ }
34
+ return parsed.endOf("day").toISO({suppressMilliseconds: false}) ?? isoValue;
35
+ };
36
+
37
+ /** Escape user input for case-insensitive MongoDB $regex literals. */
38
+ export const escapeRegexLiteral = (value: string): string => {
39
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
40
+ };
41
+
42
+ export interface BuildDataTableListQueryInput {
43
+ columns: DataTableColumn[];
44
+ filters?: DataTableColumnFilter[];
45
+ filterValues?: Record<string, unknown>;
46
+ search?: string;
47
+ searchFields?: string[];
48
+ }
49
+
50
+ const isNonEmptyString = (value: unknown): string | undefined => {
51
+ if (typeof value !== "string") {
52
+ return undefined;
53
+ }
54
+ const trimmed = value.trim();
55
+ return trimmed === "" ? undefined : trimmed;
56
+ };
57
+
58
+ const parseNumberRange = (value: unknown): {$gte?: number; $lte?: number} | undefined => {
59
+ if (value == null || typeof value !== "object" || Array.isArray(value)) {
60
+ return undefined;
61
+ }
62
+ const record = value as {$gte?: unknown; $lte?: unknown; gte?: unknown; lte?: unknown};
63
+ const range: {$gte?: number; $lte?: number} = {};
64
+ const gte = record.$gte ?? record.gte;
65
+ const lte = record.$lte ?? record.lte;
66
+ if (typeof gte === "number" && !Number.isNaN(gte)) {
67
+ range.$gte = gte;
68
+ }
69
+ if (typeof lte === "number" && !Number.isNaN(lte)) {
70
+ range.$lte = lte;
71
+ }
72
+ return Object.keys(range).length > 0 ? range : undefined;
73
+ };
74
+
75
+ const parseChoiceValues = (value: unknown): string[] => {
76
+ if (Array.isArray(value)) {
77
+ return value.map((entry) => String(entry)).filter((entry) => entry !== "");
78
+ }
79
+ if (typeof value === "string" && value.trim() !== "") {
80
+ return [value.trim()];
81
+ }
82
+ return [];
83
+ };
84
+
85
+ const splitChoiceValues = (
86
+ values: string[],
87
+ allowEmpty: boolean
88
+ ): {concrete: string[]; includeEmpty: boolean} => {
89
+ const includeEmpty = allowEmpty && values.includes(DATA_TABLE_CHOICE_EMPTY_VALUE);
90
+ const concrete = values.filter(
91
+ (entry) => entry !== DATA_TABLE_CHOICE_EMPTY_VALUE && entry !== ""
92
+ );
93
+ return {concrete, includeEmpty};
94
+ };
95
+
96
+ /**
97
+ * Builds a modelRouter-compatible choice filter value.
98
+ *
99
+ * Contract:
100
+ * - concrete only, one value → scalar equality
101
+ * - concrete only, many values → `{ $in: concrete[] }`
102
+ * - empty only → `{ $in: [DATA_TABLE_CHOICE_EMPTY_VALUE] }` (parsed server-side to null)
103
+ * - empty + concrete → `{ $in: [...concrete, DATA_TABLE_CHOICE_EMPTY_VALUE] }`
104
+ */
105
+ export const buildChoiceFilterQueryValue = (
106
+ values: string[],
107
+ allowEmpty = false
108
+ ): string | {$in: string[]} | undefined => {
109
+ const {concrete, includeEmpty} = splitChoiceValues(values, allowEmpty);
110
+ if (!includeEmpty && concrete.length === 0) {
111
+ return undefined;
112
+ }
113
+ if (includeEmpty && concrete.length === 0) {
114
+ return {$in: [DATA_TABLE_CHOICE_EMPTY_VALUE]};
115
+ }
116
+ if (!includeEmpty && concrete.length === 1) {
117
+ return concrete[0];
118
+ }
119
+ if (!includeEmpty) {
120
+ return {$in: concrete};
121
+ }
122
+ return {$in: [...concrete, DATA_TABLE_CHOICE_EMPTY_VALUE]};
123
+ };
124
+
125
+ /**
126
+ * Builds modelRouter-compatible list query params from DataTable search and filter state.
127
+ * Omits empty values. Does not include page, limit, or sort.
128
+ */
129
+ export const buildDataTableListQuery = ({
130
+ columns,
131
+ filters = [],
132
+ filterValues = {},
133
+ search = "",
134
+ searchFields = [],
135
+ }: BuildDataTableListQueryInput): DataTableQueryParams => {
136
+ const params: DataTableQueryParams = {};
137
+
138
+ const declaredFilters = [
139
+ ...columns
140
+ .map((column) => column.filter)
141
+ .filter((filter): filter is DataTableColumnFilter => Boolean(filter)),
142
+ ...filters,
143
+ ];
144
+ for (const filter of declaredFilters) {
145
+ const field = filter.field;
146
+
147
+ if (filter.kind === "text") {
148
+ const text = isNonEmptyString(filterValues[field]);
149
+ if (text) {
150
+ params[field] = {$options: "i", $regex: escapeRegexLiteral(text)};
151
+ }
152
+ continue;
153
+ }
154
+
155
+ if (filter.kind === "boolean") {
156
+ const value = filterValues[field];
157
+ if (value === true || value === false) {
158
+ params[field] = value;
159
+ }
160
+ continue;
161
+ }
162
+
163
+ if (filter.kind === "dateRange") {
164
+ const gte = isNonEmptyString(filterValues[`${field}_gte`]);
165
+ const lte = isNonEmptyString(filterValues[`${field}_lte`]);
166
+ if (gte) {
167
+ params[`${field}_gte`] = gte;
168
+ }
169
+ if (lte) {
170
+ params[`${field}_lte`] = lte;
171
+ }
172
+ continue;
173
+ }
174
+
175
+ if (filter.kind === "numberRange") {
176
+ const range = parseNumberRange(filterValues[field]);
177
+ if (range) {
178
+ params[field] = range;
179
+ }
180
+ continue;
181
+ }
182
+
183
+ if (filter.kind === "choice") {
184
+ const values = parseChoiceValues(filterValues[field]);
185
+ const queryValue = buildChoiceFilterQueryValue(values, filter.allowEmpty === true);
186
+ if (queryValue !== undefined) {
187
+ params[field] = queryValue;
188
+ }
189
+ }
190
+ }
191
+
192
+ const trimmedSearch = search.trim();
193
+ if (trimmedSearch && searchFields.length > 0) {
194
+ const escaped = escapeRegexLiteral(trimmedSearch);
195
+ params.$or = searchFields.map((field) => ({
196
+ [field]: {$options: "i", $regex: escaped},
197
+ }));
198
+ }
199
+
200
+ return params;
201
+ };
package/src/index.tsx CHANGED
@@ -5,10 +5,18 @@ export * from "./ActionSheet";
5
5
  export * from "./AddressField";
6
6
  export type * from "./AIRequestExplorer";
7
7
  export type * from "./AiSuggestionBox";
8
+ export type * from "./AnnouncementBanner";
9
+ export * from "./AnnouncementBanner";
10
+ export type * from "./AnnouncementNavigator";
11
+ export * from "./AnnouncementNavigator";
12
+ export type * from "./AnnouncementScreen";
13
+ export * from "./AnnouncementScreen";
14
+ export type * from "./AreaChart";
8
15
  export type * from "./AttachmentPreview";
9
16
  export * from "./Avatar";
10
17
  export * from "./Badge";
11
18
  export {Banner, hideBanner} from "./Banner";
19
+ export type * from "./BarChart";
12
20
  export * from "./Body";
13
21
  export * from "./BooleanField";
14
22
  export * from "./Box";
@@ -22,12 +30,15 @@ export type * from "./ConsentNavigator";
22
30
  export * from "./Constants";
23
31
  export * from "./CustomSelectField";
24
32
  export * from "./conflictFieldDiff";
33
+ export * from "./DashboardGrid";
25
34
  export * from "./DataTable";
26
35
  export * from "./DateTimeActionSheet";
27
36
  export * from "./DateTimeField";
28
37
  export * from "./DateUtilities";
29
38
  export * from "./DecimalRangeActionSheet";
30
39
  export * from "./DismissButton";
40
+ export type * from "./DonutChart";
41
+ export * from "./dataTableListQuery";
31
42
  export * from "./EditableCard";
32
43
  export * from "./EmailField";
33
44
  export * from "./ErrorBoundary";
@@ -53,18 +64,23 @@ export * from "./ImageBackground";
53
64
  export * from "./InfoModalIcon";
54
65
  export * from "./InfoTooltipButton";
55
66
  export * from "./icons/BarsFilterIcon";
67
+ export type * from "./LineChart";
56
68
  export * from "./Link";
57
69
  export {
58
70
  AIRequestExplorer,
59
71
  AiSuggestionBox,
72
+ AreaChart,
60
73
  AttachmentPreview,
74
+ BarChart,
61
75
  ConflictSheet,
62
76
  ConsentFormScreen,
63
77
  ConsentNavigator,
78
+ DonutChart,
64
79
  DraggableList,
65
80
  EmojiSelector,
66
81
  GPTChat,
67
82
  GPTMemoryModal,
83
+ LineChart,
68
84
  MarkdownEditor,
69
85
  MarkdownEditorField,
70
86
  UpgradeRequiredScreen,
@@ -79,6 +95,9 @@ export * from "./MobileAddressAutoComplete";
79
95
  export * from "./Modal";
80
96
  export * from "./ModalSheet";
81
97
  export * from "./MultiselectField";
98
+ export * from "./NotificationBell";
99
+ export * from "./NotificationInbox";
100
+ export * from "./NotificationPreferences";
82
101
  export * from "./NumberField";
83
102
  export * from "./NumberPickerActionSheet";
84
103
  export * from "./OfflineBanner";
@@ -151,6 +170,8 @@ export * from "./Unifier";
151
170
  export type * from "./UpgradeRequiredScreen";
152
171
  export * from "./UserInactivity";
153
172
  export * from "./Utilities";
173
+ export * from "./useAcknowledgeAnnouncement";
174
+ export * from "./useAnnouncements";
154
175
  export * from "./useAppLaunchOrForeground";
155
176
  export * from "./useConsentForms";
156
177
  export * from "./useStoredState";
@@ -159,7 +180,6 @@ export * from "./WebAddressAutocomplete";
159
180
 
160
181
  // export * from "./Layout";
161
182
  // export * from "./Drawer";
162
- // export * from "./Chart";
163
183
 
164
184
  // Lifted from react-native
165
185
  type ImageRequireSource = number;
@@ -1,14 +1,18 @@
1
1
  import type {AIRequestExplorer as AIRequestExplorerComponent} from "../AIRequestExplorer";
2
2
  import type {AiSuggestionBox as AiSuggestionBoxComponent} from "../AiSuggestionBox";
3
+ import type {AreaChart as AreaChartComponent} from "../AreaChart";
3
4
  import type {AttachmentPreview as AttachmentPreviewComponent} from "../AttachmentPreview";
5
+ import type {BarChart as BarChartComponent} from "../BarChart";
4
6
  import type {ConflictSheet as ConflictSheetComponent} from "../ConflictSheet";
5
7
  import type {ConsentFormScreen as ConsentFormScreenComponent} from "../ConsentFormScreen";
6
8
  import type {ConsentNavigator as ConsentNavigatorComponent} from "../ConsentNavigator";
9
+ import type {DonutChart as DonutChartComponent} from "../DonutChart";
7
10
  import type {DraggableList as DraggableListComponent} from "../DraggableList";
8
11
  import type EmojiSelectorComponent from "../EmojiSelector";
9
12
  import {Categories} from "../emojiCategories";
10
13
  import type {GPTChat as GPTChatComponent} from "../GPTChat";
11
14
  import type {GPTMemoryModal as GPTMemoryModalComponent} from "../GPTMemoryModal";
15
+ import type {LineChart as LineChartComponent} from "../LineChart";
12
16
  import type {MarkdownEditor as MarkdownEditorComponent} from "../MarkdownEditor";
13
17
  import type {MarkdownEditorField as MarkdownEditorFieldComponent} from "../MarkdownEditorField";
14
18
  import type {UpgradeRequiredScreen as UpgradeRequiredScreenComponent} from "../UpgradeRequiredScreen";
@@ -17,14 +21,18 @@ import {createLazyComponentExport, createLazyNamedExport} from "./createLazyComp
17
21
  export const heavyOptionalModuleFactories = {
18
22
  AIRequestExplorer: () => import("../AIRequestExplorer"),
19
23
  AiSuggestionBox: () => import("../AiSuggestionBox"),
24
+ AreaChart: () => import("../AreaChart"),
20
25
  AttachmentPreview: () => import("../AttachmentPreview"),
26
+ BarChart: () => import("../BarChart"),
21
27
  ConflictSheet: () => import("../ConflictSheet"),
22
28
  ConsentFormScreen: () => import("../ConsentFormScreen"),
23
29
  ConsentNavigator: () => import("../ConsentNavigator"),
30
+ DonutChart: () => import("../DonutChart"),
24
31
  DraggableList: () => import("../DraggableList"),
25
32
  EmojiSelector: () => import("../EmojiSelector"),
26
33
  GPTChat: () => import("../GPTChat"),
27
34
  GPTMemoryModal: () => import("../GPTMemoryModal"),
35
+ LineChart: () => import("../LineChart"),
28
36
  MarkdownEditor: () => import("../MarkdownEditor"),
29
37
  MarkdownEditorField: () => import("../MarkdownEditorField"),
30
38
  UpgradeRequiredScreen: () => import("../UpgradeRequiredScreen"),
@@ -46,6 +54,11 @@ export const AIRequestExplorer = createLazyNamedExport(
46
54
  "AIRequestExplorer"
47
55
  ) as unknown as typeof AIRequestExplorerComponent;
48
56
 
57
+ export const AreaChart = createLazyNamedExport(
58
+ heavyOptionalModuleFactories.AreaChart,
59
+ "AreaChart"
60
+ ) as unknown as typeof AreaChartComponent;
61
+
49
62
  export const AiSuggestionBox = createLazyNamedExport(
50
63
  heavyOptionalModuleFactories.AiSuggestionBox,
51
64
  "AiSuggestionBox"
@@ -56,6 +69,11 @@ export const AttachmentPreview = createLazyNamedExport(
56
69
  "AttachmentPreview"
57
70
  ) as unknown as typeof AttachmentPreviewComponent;
58
71
 
72
+ export const BarChart = createLazyNamedExport(
73
+ heavyOptionalModuleFactories.BarChart,
74
+ "BarChart"
75
+ ) as unknown as typeof BarChartComponent;
76
+
59
77
  export const ConflictSheet = createLazyNamedExport(
60
78
  heavyOptionalModuleFactories.ConflictSheet,
61
79
  "ConflictSheet"
@@ -71,6 +89,11 @@ export const ConsentNavigator = createLazyNamedExport(
71
89
  "ConsentNavigator"
72
90
  ) as unknown as typeof ConsentNavigatorComponent;
73
91
 
92
+ export const DonutChart = createLazyNamedExport(
93
+ heavyOptionalModuleFactories.DonutChart,
94
+ "DonutChart"
95
+ ) as unknown as typeof DonutChartComponent;
96
+
74
97
  export const DraggableList = createLazyNamedExport(
75
98
  heavyOptionalModuleFactories.DraggableList,
76
99
  "DraggableList"
@@ -85,6 +108,11 @@ export const GPTChat = createLazyNamedExport(
85
108
  "GPTChat"
86
109
  ) as unknown as typeof GPTChatComponent;
87
110
 
111
+ export const LineChart = createLazyNamedExport(
112
+ heavyOptionalModuleFactories.LineChart,
113
+ "LineChart"
114
+ ) as unknown as typeof LineChartComponent;
115
+
88
116
  export const GPTMemoryModal = createLazyNamedExport(
89
117
  heavyOptionalModuleFactories.GPTMemoryModal,
90
118
  "GPTMemoryModal"
@@ -224,6 +224,28 @@ exports[`LoginScreen renders correctly with all props 1`] = `
224
224
  },
225
225
  "type": "TextInput",
226
226
  },
227
+ {
228
+ "$$typeof": Symbol(react.test.json),
229
+ "children": null,
230
+ "props": {
231
+ "accessibilityLabel": "Show password",
232
+ "accessibilityRole": "button",
233
+ "accessibilityState": {
234
+ "disabled": true,
235
+ "expanded": false,
236
+ },
237
+ "disabled": true,
238
+ "hitSlop": 8,
239
+ "onPress": [Function],
240
+ "style": {
241
+ "alignItems": "center",
242
+ "marginLeft": 8,
243
+ "width": 20,
244
+ },
245
+ "testID": "login-screen-password-input.visibility-toggle",
246
+ },
247
+ "type": "Pressable",
248
+ },
227
249
  ],
228
250
  "props": {
229
251
  "style": {
@@ -0,0 +1,53 @@
1
+ import {describe, expect, it} from "bun:test";
2
+ import {
3
+ isEmbeddableMediaUrl,
4
+ isLoomUrl,
5
+ isYouTubeUrl,
6
+ toLoomEmbedUrl,
7
+ toMediaEmbedUrl,
8
+ toYouTubeEmbedUrl,
9
+ } from "./markdownEmbeds";
10
+
11
+ describe("markdownEmbeds", () => {
12
+ it("detects YouTube URLs", () => {
13
+ expect(isYouTubeUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ")).toBe(true);
14
+ expect(isYouTubeUrl("https://youtu.be/dQw4w9WgXcQ")).toBe(true);
15
+ expect(isYouTubeUrl("https://example.com")).toBe(false);
16
+ });
17
+
18
+ it("detects Loom URLs", () => {
19
+ expect(isLoomUrl("https://www.loom.com/share/abc123def456")).toBe(true);
20
+ expect(isLoomUrl("https://example.com")).toBe(false);
21
+ });
22
+
23
+ it("converts media URLs to embed URLs", () => {
24
+ expect(toYouTubeEmbedUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ")).toBe(
25
+ "https://www.youtube.com/embed/dQw4w9WgXcQ"
26
+ );
27
+ expect(toYouTubeEmbedUrl("https://youtu.be/dQw4w9WgXcQ")).toBe(
28
+ "https://www.youtube.com/embed/dQw4w9WgXcQ"
29
+ );
30
+ expect(toLoomEmbedUrl("https://www.loom.com/share/abc123def456")).toBe(
31
+ "https://www.loom.com/embed/abc123def456"
32
+ );
33
+ expect(toMediaEmbedUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ")).toContain("embed");
34
+ });
35
+
36
+ it("identifies embeddable media URLs", () => {
37
+ expect(isEmbeddableMediaUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ")).toBe(true);
38
+ expect(isEmbeddableMediaUrl("https://www.loom.com/share/abc123def456")).toBe(true);
39
+ expect(isEmbeddableMediaUrl("https://example.com/docs")).toBe(false);
40
+ });
41
+
42
+ it("handles alternate YouTube URL shapes and invalid input", () => {
43
+ expect(toYouTubeEmbedUrl("https://www.youtube.com/embed/dQw4w9WgXcQ")).toBe(
44
+ "https://www.youtube.com/embed/dQw4w9WgXcQ"
45
+ );
46
+ expect(toYouTubeEmbedUrl("https://www.youtube.com/shorts/dQw4w9WgXcQ")).toBe(
47
+ "https://www.youtube.com/embed/dQw4w9WgXcQ"
48
+ );
49
+ expect(toYouTubeEmbedUrl("not-a-url")).toBeNull();
50
+ expect(toLoomEmbedUrl("not-a-url")).toBeNull();
51
+ expect(toMediaEmbedUrl("https://example.com/video")).toBeNull();
52
+ });
53
+ });
@@ -0,0 +1,62 @@
1
+ const YOUTUBE_HOST_PATTERN = /(?:youtube\.com|youtu\.be)/i;
2
+ const LOOM_HOST_PATTERN = /loom\.com/i;
3
+
4
+ export const isYouTubeUrl = (url: string): boolean => YOUTUBE_HOST_PATTERN.test(url);
5
+
6
+ export const isLoomUrl = (url: string): boolean => LOOM_HOST_PATTERN.test(url);
7
+
8
+ export const isEmbeddableMediaUrl = (url: string): boolean => isYouTubeUrl(url) || isLoomUrl(url);
9
+
10
+ const extractYouTubeId = (url: string): string | null => {
11
+ try {
12
+ const parsed = new URL(url);
13
+ if (parsed.hostname === "youtu.be") {
14
+ return parsed.pathname.replace(/^\//, "") || null;
15
+ }
16
+ if (parsed.pathname.startsWith("/embed/")) {
17
+ return parsed.pathname.split("/")[2] ?? null;
18
+ }
19
+ if (parsed.pathname.startsWith("/shorts/")) {
20
+ return parsed.pathname.split("/")[2] ?? null;
21
+ }
22
+ return parsed.searchParams.get("v");
23
+ } catch {
24
+ return null;
25
+ }
26
+ };
27
+
28
+ const extractLoomId = (url: string): string | null => {
29
+ try {
30
+ const parsed = new URL(url);
31
+ const match = parsed.pathname.match(/\/share\/([^/?#]+)/i);
32
+ return match?.[1] ?? null;
33
+ } catch {
34
+ return null;
35
+ }
36
+ };
37
+
38
+ export const toYouTubeEmbedUrl = (url: string): string | null => {
39
+ const videoId = extractYouTubeId(url);
40
+ if (!videoId) {
41
+ return null;
42
+ }
43
+ return `https://www.youtube.com/embed/${videoId}`;
44
+ };
45
+
46
+ export const toLoomEmbedUrl = (url: string): string | null => {
47
+ const videoId = extractLoomId(url);
48
+ if (!videoId) {
49
+ return null;
50
+ }
51
+ return `https://www.loom.com/embed/${videoId}`;
52
+ };
53
+
54
+ export const toMediaEmbedUrl = (url: string): string | null => {
55
+ if (isYouTubeUrl(url)) {
56
+ return toYouTubeEmbedUrl(url);
57
+ }
58
+ if (isLoomUrl(url)) {
59
+ return toLoomEmbedUrl(url);
60
+ }
61
+ return null;
62
+ };
@@ -0,0 +1,119 @@
1
+ import {describe, expect, it, mock} from "bun:test";
2
+ import {Platform} from "react-native";
3
+
4
+ import {buildConsentPdfHtml, type PdfTemplateData, sharePdfFromHtml} from "./pdfHtmlTemplate";
5
+
6
+ const printToFileAsync = mock(() => Promise.resolve({uri: "file:///tmp/consent.pdf"}));
7
+ const shareAsync = mock(() => Promise.resolve());
8
+
9
+ mock.module("expo-print", () => ({printToFileAsync}));
10
+ mock.module("expo-sharing", () => ({shareAsync}));
11
+
12
+ const baseData: PdfTemplateData = {
13
+ fields: [
14
+ {label: "Full Name", value: "Jane <Doe>"},
15
+ {label: "Notes", value: 'Says "hi" & bye'},
16
+ ],
17
+ formTitle: "Consent & Release",
18
+ title: "Consent Record",
19
+ };
20
+
21
+ describe("buildConsentPdfHtml", () => {
22
+ it("renders the required sections and escapes HTML", () => {
23
+ const html = buildConsentPdfHtml(baseData);
24
+
25
+ expect(html).toStartWith("<!DOCTYPE html>");
26
+ expect(html).toContain("<h1>Consent Record</h1>");
27
+ expect(html).toContain('<div class="form-title">Consent &amp; Release</div>');
28
+ expect(html).toContain('<td class="field-value">Jane &lt;Doe&gt;</td>');
29
+ expect(html).toContain('<td class="field-value">Says &quot;hi&quot; &amp; bye</td>');
30
+ expect(html).toContain("<h2>Response Details</h2>");
31
+ expect(html).toMatch(/<span>Generated .+<\/span>/);
32
+
33
+ expect(html).not.toContain("<h2>User Information</h2>");
34
+ expect(html).not.toContain("<h2>Checkbox Responses</h2>");
35
+ expect(html).not.toContain("<h2>Audit Trail</h2>");
36
+ expect(html).not.toContain("<h2>Signature</h2>");
37
+ expect(html).not.toContain("<h2>Content Snapshot</h2>");
38
+ expect(html).not.toContain("Response ID:");
39
+ });
40
+
41
+ it("renders user info, checkboxes, audit trail, signature, snapshot and response id", () => {
42
+ const html = buildConsentPdfHtml({
43
+ ...baseData,
44
+ auditTrail: [{label: "Signed At", value: "2025-01-01"}],
45
+ checkboxes: [
46
+ {checked: true, label: "I agree"},
47
+ {checked: false, label: "Send me <updates>"},
48
+ ],
49
+ contentSnapshot: "Line one <b>bold</b>",
50
+ responseId: "resp_123",
51
+ signature: 'data:image/png;base64,abc"def',
52
+ userInfo: {email: "jane@example.com", name: "Jane Doe", userId: "user_1"},
53
+ });
54
+
55
+ expect(html).toContain("<h2>User Information</h2>");
56
+ expect(html).toContain('<td class="field-label">User ID:</td>');
57
+ expect(html).toContain('<td class="field-value">user_1</td>');
58
+ expect(html).toContain('<td class="field-value">Jane Doe</td>');
59
+ expect(html).toContain('<td class="field-value">jane@example.com</td>');
60
+
61
+ expect(html).toContain("<h2>Checkbox Responses</h2>");
62
+ expect(html).toContain('<div class="checkbox-row">&#9745; I agree</div>');
63
+ expect(html).toContain('<div class="checkbox-row">&#9744; Send me &lt;updates&gt;</div>');
64
+
65
+ expect(html).toContain("<h2>Audit Trail</h2>");
66
+ expect(html).toContain('<td class="field-label">Signed At</td>');
67
+
68
+ expect(html).toContain("<h2>Signature</h2>");
69
+ expect(html).toContain(
70
+ '<img src="data:image/png;base64,abc&quot;def" class="signature-img" />'
71
+ );
72
+
73
+ expect(html).toContain("<h2>Content Snapshot</h2>");
74
+ expect(html).toContain('<div class="content-snapshot">Line one &lt;b&gt;bold&lt;/b&gt;</div>');
75
+
76
+ expect(html).toContain("<span>Response ID: resp_123</span>");
77
+ });
78
+
79
+ it("omits optional user info rows that are not provided", () => {
80
+ const html = buildConsentPdfHtml({...baseData, userInfo: {userId: "user_2"}});
81
+
82
+ expect(html).toContain('<td class="field-value">user_2</td>');
83
+ expect(html).not.toContain('<td class="field-label">Name:</td>');
84
+ expect(html).not.toContain('<td class="field-label">Email:</td>');
85
+ });
86
+
87
+ it("treats empty checkbox and audit trail lists as absent sections", () => {
88
+ const html = buildConsentPdfHtml({...baseData, auditTrail: [], checkboxes: []});
89
+
90
+ expect(html).not.toContain("<h2>Checkbox Responses</h2>");
91
+ expect(html).not.toContain("<h2>Audit Trail</h2>");
92
+ });
93
+ });
94
+
95
+ describe("sharePdfFromHtml", () => {
96
+ it("throws on web", async () => {
97
+ const originalOS = Platform.OS;
98
+ Platform.OS = "web";
99
+ try {
100
+ await expect(sharePdfFromHtml({filename: "consent.pdf", html: "<p>hi</p>"})).rejects.toThrow(
101
+ "sharePdfFromHtml is only supported on mobile platforms"
102
+ );
103
+ } finally {
104
+ Platform.OS = originalOS;
105
+ }
106
+ expect(printToFileAsync).not.toHaveBeenCalled();
107
+ });
108
+
109
+ it("prints to a file and shares it on native", async () => {
110
+ await sharePdfFromHtml({filename: "consent.pdf", html: "<p>hi</p>"});
111
+
112
+ expect(printToFileAsync).toHaveBeenCalledWith({html: "<p>hi</p>"});
113
+ expect(shareAsync).toHaveBeenCalledWith("file:///tmp/consent.pdf", {
114
+ dialogTitle: "consent.pdf",
115
+ mimeType: "application/pdf",
116
+ UTI: "com.adobe.pdf",
117
+ });
118
+ });
119
+ });
@@ -330,6 +330,28 @@ exports[`SignUpScreen renders correctly with all props 1`] = `
330
330
  },
331
331
  "type": "TextInput",
332
332
  },
333
+ {
334
+ "$$typeof": Symbol(react.test.json),
335
+ "children": null,
336
+ "props": {
337
+ "accessibilityLabel": "Show password",
338
+ "accessibilityRole": "button",
339
+ "accessibilityState": {
340
+ "disabled": true,
341
+ "expanded": false,
342
+ },
343
+ "disabled": true,
344
+ "hitSlop": 8,
345
+ "onPress": [Function],
346
+ "style": {
347
+ "alignItems": "center",
348
+ "marginLeft": 8,
349
+ "width": 20,
350
+ },
351
+ "testID": "signup-screen-password-input.visibility-toggle",
352
+ },
353
+ "type": "Pressable",
354
+ },
333
355
  ],
334
356
  "props": {
335
357
  "style": {