@terreno/ui 0.14.0 → 0.14.2

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 (98) hide show
  1. package/dist/ActionSheet.d.ts +1 -1
  2. package/dist/ActionSheet.js +17 -29
  3. package/dist/ActionSheet.js.map +1 -1
  4. package/dist/Common.d.ts +8 -2
  5. package/dist/Common.js +4 -4
  6. package/dist/Common.js.map +1 -1
  7. package/dist/ConsentFormScreen.js +3 -3
  8. package/dist/ConsentFormScreen.js.map +1 -1
  9. package/dist/DateUtilities.d.ts +25 -25
  10. package/dist/DateUtilities.js +31 -32
  11. package/dist/DateUtilities.js.map +1 -1
  12. package/dist/MarkdownView.js +20 -7
  13. package/dist/MarkdownView.js.map +1 -1
  14. package/dist/MediaQuery.d.ts +4 -4
  15. package/dist/MediaQuery.js +8 -8
  16. package/dist/MediaQuery.js.map +1 -1
  17. package/dist/Page.d.ts +1 -0
  18. package/dist/Page.js +6 -2
  19. package/dist/Page.js.map +1 -1
  20. package/dist/PickerSelect.d.ts +1 -1
  21. package/dist/PickerSelect.js +2 -2
  22. package/dist/PickerSelect.js.map +1 -1
  23. package/dist/TapToEdit.d.ts +1 -1
  24. package/dist/TapToEdit.js +2 -3
  25. package/dist/TapToEdit.js.map +1 -1
  26. package/dist/ToastNotifications.js +2 -2
  27. package/dist/ToastNotifications.js.map +1 -1
  28. package/dist/Tooltip.d.ts +24 -1
  29. package/dist/Tooltip.js +2 -2
  30. package/dist/Tooltip.js.map +1 -1
  31. package/dist/Unifier.d.ts +1 -1
  32. package/dist/Unifier.js +14 -11
  33. package/dist/Unifier.js.map +1 -1
  34. package/dist/Utilities.d.ts +8 -8
  35. package/dist/Utilities.js +12 -14
  36. package/dist/Utilities.js.map +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/signUp/PasswordRequirements.js +3 -3
  41. package/dist/signUp/PasswordRequirements.js.map +1 -1
  42. package/dist/table/TableHeaderCell.js +1 -9
  43. package/dist/table/TableHeaderCell.js.map +1 -1
  44. package/dist/table/tableContext.d.ts +1 -1
  45. package/dist/table/tableContext.js +2 -2
  46. package/dist/table/tableContext.js.map +1 -1
  47. package/dist/useConsentHistory.d.ts +6 -1
  48. package/dist/useConsentHistory.js +2 -1
  49. package/dist/useConsentHistory.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/ActionSheet.test.tsx +554 -0
  52. package/src/ActionSheet.tsx +26 -39
  53. package/src/Banner.test.tsx +107 -1
  54. package/src/Common.ts +10 -4
  55. package/src/ConsentFormScreen.test.tsx +22 -0
  56. package/src/ConsentFormScreen.tsx +9 -3
  57. package/src/DataTable.test.tsx +393 -1
  58. package/src/DateTimeField.test.tsx +716 -2
  59. package/src/DateUtilities.tsx +37 -38
  60. package/src/HeightActionSheet.test.tsx +17 -1
  61. package/src/HeightField.test.tsx +141 -1
  62. package/src/HeightFieldDesktop.test.tsx +19 -0
  63. package/src/MarkdownView.test.tsx +28 -0
  64. package/src/MarkdownView.tsx +69 -7
  65. package/src/MediaQuery.ts +8 -8
  66. package/src/MobileAddressAutoComplete.test.tsx +26 -3
  67. package/src/Page.test.tsx +28 -0
  68. package/src/Page.tsx +17 -2
  69. package/src/PickerSelect.test.tsx +243 -0
  70. package/src/PickerSelect.tsx +3 -3
  71. package/src/SplitPage.test.tsx +299 -43
  72. package/src/TapToEdit.test.tsx +44 -0
  73. package/src/TapToEdit.tsx +2 -3
  74. package/src/ToastNotifications.test.tsx +1412 -0
  75. package/src/ToastNotifications.tsx +2 -2
  76. package/src/Tooltip.test.tsx +1294 -3
  77. package/src/Tooltip.tsx +2 -2
  78. package/src/Unifier.ts +14 -11
  79. package/src/Utilities.tsx +14 -16
  80. package/src/WebAddressAutocomplete.test.tsx +237 -0
  81. package/src/WebDropdownMenu.test.tsx +51 -2
  82. package/src/__snapshots__/Banner.test.tsx.snap +125 -0
  83. package/src/__snapshots__/DataTable.test.tsx.snap +366 -0
  84. package/src/__snapshots__/MarkdownView.test.tsx.snap +284 -74
  85. package/src/__snapshots__/SplitPage.test.tsx.snap +698 -46
  86. package/src/bunSetup.ts +0 -4
  87. package/src/index.tsx +1 -1
  88. package/src/login/LoginScreen.test.tsx +35 -1
  89. package/src/signUp/PasswordRequirements.tsx +9 -6
  90. package/src/signUp/__snapshots__/PasswordRequirements.test.tsx.snap +50 -2
  91. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +25 -1
  92. package/src/table/TableHeaderCell.tsx +8 -11
  93. package/src/table/TableRow.test.tsx +31 -1
  94. package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +2 -0
  95. package/src/table/tableContext.tsx +2 -2
  96. package/src/useConsentHistory.test.ts +20 -13
  97. package/src/useConsentHistory.ts +7 -2
  98. package/src/useStoredState.test.tsx +47 -0
@@ -7,7 +7,7 @@ const getErrorMessage = (error: unknown): string => {
7
7
  return String(error);
8
8
  };
9
9
 
10
- function getDate(date: string, {timezone}: {timezone?: string} = {}): DateTime {
10
+ const getDate = (date: string, {timezone}: {timezone?: string} = {}): DateTime => {
11
11
  if (!date) {
12
12
  throw new Error("Passed undefined");
13
13
  }
@@ -19,48 +19,48 @@ function getDate(date: string, {timezone}: {timezone?: string} = {}): DateTime {
19
19
  throw new Error(`Invalid date: ${date}`);
20
20
  }
21
21
  return clonedDate;
22
- }
22
+ };
23
23
 
24
- export function isTomorrow(date: string, {timezone}: {timezone?: string} = {}): boolean {
24
+ export const isTomorrow = (date: string, {timezone}: {timezone?: string} = {}): boolean => {
25
25
  const clonedDate = getDate(date, {timezone});
26
26
  const now = timezone ? DateTime.now().setZone(timezone) : DateTime.now();
27
27
  const diff = now.startOf("day").diff(clonedDate.startOf("day"), "days");
28
28
  return diff.days <= -1 && diff.days > -2;
29
- }
29
+ };
30
30
 
31
- export function isYesterday(date: string, {timezone}: {timezone?: string} = {}): boolean {
31
+ export const isYesterday = (date: string, {timezone}: {timezone?: string} = {}): boolean => {
32
32
  const clonedDate = getDate(date, {timezone});
33
33
  const now = timezone ? DateTime.now().setZone(timezone) : DateTime.now();
34
34
  const diff = now.startOf("day").diff(clonedDate.startOf("day"), "days");
35
35
  return diff.days <= 1 && diff.days > -1;
36
- }
36
+ };
37
37
 
38
- export function isToday(date: string, {timezone}: {timezone?: string} = {}): boolean {
38
+ export const isToday = (date: string, {timezone}: {timezone?: string} = {}): boolean => {
39
39
  const clonedDate = getDate(date, {timezone});
40
40
  const now = timezone ? DateTime.now().setZone(timezone) : DateTime.now();
41
41
  const diff = now.startOf("day").diff(clonedDate.startOf("day"), "days");
42
42
  return diff.days === 0;
43
- }
43
+ };
44
44
 
45
- export function isThisYear(date: string, {timezone}: {timezone?: string} = {}): boolean {
45
+ export const isThisYear = (date: string, {timezone}: {timezone?: string} = {}): boolean => {
46
46
  const clonedDate = getDate(date, {timezone});
47
47
  const now = timezone ? DateTime.now().setZone(timezone) : DateTime.now();
48
48
  return clonedDate.year === now.year;
49
- }
49
+ };
50
50
 
51
- export function isWithinWeek(date: string, {timezone}: {timezone?: string} = {}): boolean {
51
+ export const isWithinWeek = (date: string, {timezone}: {timezone?: string} = {}): boolean => {
52
52
  const clonedDate = getDate(date, {timezone});
53
53
  const now = timezone ? DateTime.now().setZone(timezone) : DateTime.now();
54
54
  const diff = now.startOf("day").diff(clonedDate.startOf("day"), "days");
55
55
  return diff.days > -7 && diff.days < 7;
56
- }
56
+ };
57
57
 
58
58
  // Prints a human friendly date, e.g. "Tomorrow", "Yesterday", "Monday", "June 19", "December 25,
59
59
  // 2022".
60
- export function humanDate(
60
+ export const humanDate = (
61
61
  date: string,
62
62
  {timezone, dontShowTime}: {timezone?: string; dontShowTime?: boolean} = {}
63
- ): string {
63
+ ): string => {
64
64
  let clonedDate: DateTime;
65
65
  try {
66
66
  clonedDate = getDate(date, {timezone});
@@ -87,14 +87,14 @@ export function humanDate(
87
87
  // December 25, 2022
88
88
  return clonedDate.toFormat("MMM d, yyyy");
89
89
  }
90
- }
90
+ };
91
91
 
92
92
  // Prints a human friendly date and time, e.g. "Tomorrow 9:00 AM", "Yesterday 9:00 AM", "Monday
93
93
  // 9:00 AM", "June 19 9:00 AM", "December 25, 2022 9:00 AM".
94
- export function humanDateAndTime(
94
+ export const humanDateAndTime = (
95
95
  date: string,
96
96
  {timezone, showTimezone = true}: {timezone?: string; showTimezone?: boolean} = {}
97
- ): string {
97
+ ): string => {
98
98
  let clonedDate: DateTime;
99
99
  try {
100
100
  clonedDate = getDate(date, {timezone});
@@ -128,7 +128,7 @@ export function humanDateAndTime(
128
128
  // December 25, 2022
129
129
  return `${clonedDate.toFormat("MMM d, yyyy")} ${time}`;
130
130
  }
131
- }
131
+ };
132
132
 
133
133
  // Print date in the format of M/D/YY, taking timezones into account.
134
134
  export const printDate = (
@@ -199,7 +199,7 @@ export const printOnlyDate = (
199
199
  };
200
200
 
201
201
  // Print time in the format of HH:mm A, taking timezones into account.
202
- export function printTime(
202
+ export const printTime = (
203
203
  date?: string,
204
204
  {
205
205
  timezone,
@@ -210,7 +210,7 @@ export function printTime(
210
210
  showTimezone?: boolean;
211
211
  defaultValue?: string;
212
212
  } = {defaultValue: "Invalid Date", timezone: "America/New_York"}
213
- ): string {
213
+ ): string => {
214
214
  if (!date) {
215
215
  return defaultValue ?? "Invalid Date";
216
216
  }
@@ -232,10 +232,10 @@ export function printTime(
232
232
  } else {
233
233
  return clonedDate.toLocaleString(DateTime.TIME_SIMPLE);
234
234
  }
235
- }
235
+ };
236
236
 
237
237
  // Print date in the format of M/D/YY HH:mm A, taking timezones into account.
238
- export function printDateAndTime(
238
+ export const printDateAndTime = (
239
239
  date?: string,
240
240
  {
241
241
  timezone,
@@ -246,7 +246,7 @@ export function printDateAndTime(
246
246
  showTimezone?: boolean;
247
247
  defaultValue?: string;
248
248
  } = {}
249
- ): string {
249
+ ): string => {
250
250
  if (!date) {
251
251
  return defaultValue ?? "Invalid Datetime";
252
252
  }
@@ -268,12 +268,12 @@ export function printDateAndTime(
268
268
  } else {
269
269
  return clonedDate.toLocaleString(DateTime.DATETIME_SHORT);
270
270
  }
271
- }
271
+ };
272
272
 
273
273
  // Prints a date range in the format of M/D/YY HH:mm A - M/D/YY HH:mm A EST, taking timezones into
274
274
  // account. If the dates are the same, it will print the date only once, e.g. M/D/YY HH:mm A - HH:mm
275
275
  // A EST.
276
- export function printDateRange(
276
+ export const printDateRange = (
277
277
  start: string,
278
278
  end: string,
279
279
  {
@@ -281,7 +281,7 @@ export function printDateRange(
281
281
  showTimezone = true,
282
282
  timeOnly,
283
283
  }: {timezone: string; showTimezone?: boolean; timeOnly?: boolean}
284
- ): string {
284
+ ): string => {
285
285
  const startDate = printDate(start, {showTimezone: false, timezone});
286
286
  const endDate = printDate(end, {showTimezone: false, timezone});
287
287
 
@@ -299,14 +299,14 @@ export function printDateRange(
299
299
  } else {
300
300
  return `${startDate} ${startTime} - ${endDate} ${endTime}`;
301
301
  }
302
- }
302
+ };
303
303
 
304
304
  // Print since nicely. If less than 2 months, print days, otherwise print months. If over 1 year,
305
305
  // print years.
306
- export function printSince(
306
+ export const printSince = (
307
307
  date: string,
308
308
  {timezone, showAgo = true}: {timezone?: string; showAgo?: boolean} = {}
309
- ): string {
309
+ ): string => {
310
310
  let clonedDate: DateTime;
311
311
  const ago = showAgo ? " ago" : "";
312
312
  try {
@@ -326,20 +326,20 @@ export function printSince(
326
326
  const years = Math.floor(now.diff(clonedDate, "years").years);
327
327
  return `${years} ${years === 1 ? "year" : "years"}${ago}`;
328
328
  }
329
- }
329
+ };
330
330
 
331
- export function convertNullToUndefined(value: string | null): string | undefined {
331
+ export const convertNullToUndefined = (value: string | null): string | undefined => {
332
332
  return value ?? undefined;
333
- }
333
+ };
334
334
 
335
335
  // Get the ISO date string from a date string. If the date string is undefined,
336
336
  // return undefined instead of null so MongoDB can handle it.
337
- export function getIsoDate(date: string | undefined): string | undefined {
337
+ export const getIsoDate = (date: string | undefined): string | undefined => {
338
338
  if (!date) {
339
339
  return undefined;
340
340
  }
341
341
  return convertNullToUndefined(DateTime.fromISO(date).toUTC().toISO());
342
- }
342
+ };
343
343
 
344
344
  const usTimezoneOptions = [
345
345
  {label: "Eastern", value: "America/New_York"},
@@ -351,7 +351,7 @@ const usTimezoneOptions = [
351
351
  {label: "Arizona", value: "America/Phoenix"},
352
352
  ];
353
353
 
354
- export function getTimezoneOptions(location: "USA" | "Worldwide", shortTimezone = false) {
354
+ export const getTimezoneOptions = (location: "USA" | "Worldwide", shortTimezone = false) => {
355
355
  let timezones: [string, string][];
356
356
  if (location === "USA") {
357
357
  timezones = usTimezoneOptions.map((tz) => [tz.label, tz.value]);
@@ -366,9 +366,8 @@ export function getTimezoneOptions(location: "USA" | "Worldwide", shortTimezone
366
366
  }
367
367
  return timezones.map(([name, tz]) => {
368
368
  const dateTime = DateTime.now().setZone(tz);
369
- let tzAbbr = dateTime.toFormat("ZZZZ"); // Gets timezone abbreviation like "EST", "CST", etc.
369
+ let tzAbbr = dateTime.toFormat("ZZZZ");
370
370
 
371
- // Special case for Arizona which returns MST during standard time
372
371
  if (tz === "America/Phoenix") {
373
372
  tzAbbr = "AZ";
374
373
  }
@@ -378,4 +377,4 @@ export function getTimezoneOptions(location: "USA" | "Worldwide", shortTimezone
378
377
  value: tz,
379
378
  };
380
379
  });
381
- }
380
+ };
@@ -1,8 +1,9 @@
1
1
  import {describe, expect, it, mock} from "bun:test";
2
2
  import {act, render} from "@testing-library/react-native";
3
- import {createRef} from "react";
3
+ import React, {createRef} from "react";
4
4
 
5
5
  import type {ActionSheet} from "./ActionSheet";
6
+ import {Button} from "./Button";
6
7
  import {HeightActionSheet} from "./HeightActionSheet";
7
8
  import {ThemeProvider} from "./Theme";
8
9
 
@@ -86,4 +87,19 @@ describe("HeightActionSheet", () => {
86
87
  });
87
88
  expect(handleChange).toHaveBeenCalled();
88
89
  });
90
+
91
+ it("calls the Done button onClick handler directly", () => {
92
+ const actionSheetRef = createRef<ActionSheet>();
93
+ const {UNSAFE_root} = render(
94
+ <ThemeProvider>
95
+ <HeightActionSheet actionSheetRef={actionSheetRef} onChange={() => {}} value="60" />
96
+ </ThemeProvider>
97
+ );
98
+ const buttons = UNSAFE_root.findAllByType(Button as never);
99
+ const doneBtn = buttons.find((b) => b.props.text === "Done");
100
+ expect(doneBtn).toBeTruthy();
101
+ act(() => {
102
+ doneBtn!.props.onClick();
103
+ });
104
+ });
89
105
  });
@@ -1,8 +1,9 @@
1
- import {afterEach, beforeEach, describe, expect, it, mock} from "bun:test";
1
+ import {afterEach, beforeEach, describe, expect, it, mock, spyOn} from "bun:test";
2
2
  import {fireEvent} from "@testing-library/react-native";
3
3
  import {HeightActionSheet} from "./HeightActionSheet";
4
4
  import {HeightField} from "./HeightField";
5
5
  import {renderWithTheme} from "./test-utils";
6
+ import * as Utilities from "./Utilities";
6
7
 
7
8
  describe("HeightField", () => {
8
9
  let mockOnChange: ReturnType<typeof mock>;
@@ -207,6 +208,41 @@ describe("HeightField", () => {
207
208
  });
208
209
  });
209
210
 
211
+ describe("HeightField - HeightSegment callbacks", () => {
212
+ it("exercises HeightSegment onChangeText for feet and inches when rendered", () => {
213
+ const RN = require("react-native") as {Platform: {OS: string}};
214
+ const origOS = RN.Platform.OS;
215
+ RN.Platform.OS = "web";
216
+ try {
217
+ const onChange = mock(() => {});
218
+ const {root} = renderWithTheme(<HeightField onChange={onChange} title="Height" value="70" />);
219
+ const ftInputs = root.findAll(
220
+ (n) => n.props["aria-label"] === "ft input" && n.props.onChangeText
221
+ );
222
+ const inInputs = root.findAll(
223
+ (n) => n.props["aria-label"] === "in input" && n.props.onChangeText
224
+ );
225
+ if (ftInputs.length === 0) {
226
+ console.warn(
227
+ "Platform.OS override to 'web' did not take effect; skipping HeightSegment assertions"
228
+ );
229
+ return;
230
+ }
231
+ expect(inInputs.length).toBeGreaterThan(0);
232
+
233
+ // Exercise the callbacks to cover HeightSegment.handleChange
234
+ ftInputs[0].props.onChangeText("6");
235
+ expect(onChange).toHaveBeenCalled();
236
+
237
+ inInputs[0].props.onChangeText("3");
238
+ ftInputs[0].props.onChangeText("abc");
239
+ ftInputs[0].props.onChangeText("");
240
+ } finally {
241
+ RN.Platform.OS = origOS;
242
+ }
243
+ });
244
+ });
245
+
210
246
  describe("HeightField - Android platform", () => {
211
247
  // Toggle Platform.OS to "android" to exercise the Android rendering branch
212
248
  // that uses SelectField pickers instead of the Pressable+ActionSheet path.
@@ -274,3 +310,107 @@ describe("HeightField - Android platform", () => {
274
310
  expect(onChange).toHaveBeenCalledWith("63");
275
311
  });
276
312
  });
313
+
314
+ describe("HeightField - Desktop platform", () => {
315
+ const {Platform} = require("react-native") as {Platform: {OS: string}};
316
+ const originalOS = Platform.OS;
317
+ let isNativeSpy: ReturnType<typeof spyOn>;
318
+
319
+ beforeEach(() => {
320
+ Platform.OS = "web";
321
+ isNativeSpy = spyOn(Utilities, "isNative").mockReturnValue(false);
322
+ });
323
+
324
+ afterEach(() => {
325
+ Platform.OS = originalOS;
326
+ isNativeSpy.mockRestore();
327
+ });
328
+
329
+ it("fires handleBlur on HeightSegment and calls onChange", () => {
330
+ const onChange = mock(() => {});
331
+ const {getByLabelText} = renderWithTheme(<HeightField onChange={onChange} value="70" />);
332
+ const feetInput = getByLabelText("ft input");
333
+ fireEvent(feetInput, "blur");
334
+ expect(onChange).toHaveBeenCalled();
335
+ });
336
+
337
+ it("handles text input change in feet segment", () => {
338
+ const onChange = mock(() => {});
339
+ const {getByLabelText} = renderWithTheme(<HeightField onChange={onChange} value="70" />);
340
+ const feetInput = getByLabelText("ft input");
341
+ fireEvent.changeText(feetInput, "6");
342
+ expect(onChange).toHaveBeenCalled();
343
+ });
344
+
345
+ it("handles clearing feet input to empty", () => {
346
+ const onChange = mock(() => {});
347
+ const {getByLabelText} = renderWithTheme(<HeightField onChange={onChange} value="70" />);
348
+ const feetInput = getByLabelText("ft input");
349
+ fireEvent.changeText(feetInput, "");
350
+ expect(onChange).toHaveBeenCalled();
351
+ });
352
+
353
+ it("calls onChange with empty when both feet and inches are cleared", () => {
354
+ const onChange = mock(() => {});
355
+ const {getByLabelText} = renderWithTheme(<HeightField onChange={onChange} value="" />);
356
+ const feetInput = getByLabelText("ft input");
357
+ fireEvent.changeText(feetInput, "");
358
+ expect(onChange).toHaveBeenCalledWith("");
359
+ });
360
+
361
+ it("renders HeightSegment in disabled state", () => {
362
+ const onChange = mock(() => {});
363
+ const {getByLabelText} = renderWithTheme(
364
+ <HeightField disabled onChange={onChange} value="70" />
365
+ );
366
+ expect(getByLabelText("ft input")).toBeTruthy();
367
+ });
368
+
369
+ it("renders HeightSegment with error text", () => {
370
+ const onChange = mock(() => {});
371
+ const {getByLabelText} = renderWithTheme(
372
+ <HeightField errorText="Required" onChange={onChange} value="70" />
373
+ );
374
+ expect(getByLabelText("ft input")).toBeTruthy();
375
+ });
376
+
377
+ it("fires focus on feet segment", () => {
378
+ const onChange = mock(() => {});
379
+ const {getByLabelText} = renderWithTheme(<HeightField onChange={onChange} value="70" />);
380
+ const feetInput = getByLabelText("ft input");
381
+ fireEvent(feetInput, "focus");
382
+ expect(feetInput).toBeTruthy();
383
+ });
384
+
385
+ it("fires focus on inches segment", () => {
386
+ const onChange = mock(() => {});
387
+ const {getByLabelText} = renderWithTheme(<HeightField onChange={onChange} value="70" />);
388
+ const inInput = getByLabelText("in input");
389
+ fireEvent(inInput, "focus");
390
+ expect(inInput).toBeTruthy();
391
+ });
392
+
393
+ it("handles text input change in inches segment", () => {
394
+ const onChange = mock(() => {});
395
+ const {getByLabelText} = renderWithTheme(<HeightField onChange={onChange} value="70" />);
396
+ const inInput = getByLabelText("in input");
397
+ fireEvent.changeText(inInput, "3");
398
+ expect(onChange).toHaveBeenCalled();
399
+ });
400
+
401
+ it("handles non-numeric input in HeightSegment", () => {
402
+ const onChange = mock(() => {});
403
+ const {getByLabelText} = renderWithTheme(<HeightField onChange={onChange} value="70" />);
404
+ const feetInput = getByLabelText("ft input");
405
+ fireEvent.changeText(feetInput, "abc");
406
+ expect(onChange).toHaveBeenCalled();
407
+ });
408
+
409
+ it("clamps to max value in HeightSegment handleChange", () => {
410
+ const onChange = mock(() => {});
411
+ const {getByLabelText} = renderWithTheme(<HeightField onChange={onChange} value="70" />);
412
+ const feetInput = getByLabelText("ft input");
413
+ fireEvent.changeText(feetInput, "99");
414
+ expect(feetInput).toBeTruthy();
415
+ });
416
+ });
@@ -126,6 +126,25 @@ describe("HeightField (desktop/web path)", () => {
126
126
  expect(mockOnChange).not.toHaveBeenCalled();
127
127
  });
128
128
 
129
+ it("tracks focused segment when inputs are focused", () => {
130
+ const {getAllByLabelText, toJSON} = renderWithTheme(
131
+ <HeightField onChange={mockOnChange} value="70" />
132
+ );
133
+ const feetInput = getAllByLabelText("ft input")[0];
134
+ const inchesInput = getAllByLabelText("in input")[0];
135
+
136
+ fireEvent(feetInput, "focus");
137
+ const snapshotFeetFocused = toJSON();
138
+ fireEvent(feetInput, "blur");
139
+
140
+ fireEvent(inchesInput, "focus");
141
+ const snapshotInchesFocused = toJSON();
142
+ fireEvent(inchesInput, "blur");
143
+
144
+ expect(snapshotFeetFocused).toBeTruthy();
145
+ expect(snapshotInchesFocused).toBeTruthy();
146
+ });
147
+
129
148
  it("does not call onChange with values exceeding max feet", () => {
130
149
  const {getAllByLabelText} = renderWithTheme(
131
150
  <HeightField max={95} onChange={mockOnChange} value="" />
@@ -1,4 +1,5 @@
1
1
  import {describe, expect, it} from "bun:test";
2
+ import assert from "node:assert";
2
3
 
3
4
  import {MarkdownView} from "./MarkdownView";
4
5
  import {renderWithTheme} from "./test-utils";
@@ -38,6 +39,33 @@ describe("MarkdownView", () => {
38
39
  expect(toJSON()).toMatchSnapshot();
39
40
  });
40
41
 
42
+ it("keeps long consent ordered list markers on one line", () => {
43
+ const longConsentList = Array.from({length: 17}, (_, index) => {
44
+ return `${index + 1}. This consent item has enough text to wrap on narrow mobile screens.`;
45
+ }).join("\n");
46
+ const {toJSON} = renderWithTheme(<MarkdownView>{longConsentList}</MarkdownView>);
47
+ const serialized = JSON.stringify(toJSON());
48
+
49
+ assert.ok(serialized.includes('"minWidth":32'));
50
+ assert.ok(serialized.includes('"flexShrink":0'));
51
+ assert.ok(serialized.includes('"textAlign":"right"'));
52
+ assert.ok(serialized.includes("17"));
53
+ });
54
+
55
+ it("uses explicit markdown paragraph line height for wrapped mobile text", () => {
56
+ const {toJSON} = renderWithTheme(
57
+ <MarkdownView>
58
+ {
59
+ "This consent paragraph is intentionally long so it wraps across multiple lines on Android and keeps its measured height."
60
+ }
61
+ </MarkdownView>
62
+ );
63
+ const serialized = JSON.stringify(toJSON());
64
+
65
+ assert.ok(serialized.includes('"fontSize":14'));
66
+ assert.ok(serialized.includes('"lineHeight":20'));
67
+ });
68
+
41
69
  it("renders code blocks", () => {
42
70
  const {toJSON} = renderWithTheme(<MarkdownView>{"```\ncode block\n```"}</MarkdownView>);
43
71
  expect(toJSON()).toMatchSnapshot();
@@ -49,11 +49,29 @@ export const MarkdownView: React.FC<{children: React.ReactNode; inverted?: boole
49
49
  });
50
50
 
51
51
  const monoFont = isWeb ? "monospace" : Platform.select({android: "monospace", ios: "Menlo"});
52
+ const textFontSize = isWeb ? 16 : 14;
53
+ const textLineHeight = isWeb ? 24 : 20;
54
+ const markdownTextStyle = {
55
+ fontFamily: "text-regular",
56
+ fontSize: textFontSize,
57
+ lineHeight: textLineHeight,
58
+ ...color,
59
+ };
52
60
 
53
61
  return (
54
62
  <Markdown
55
63
  style={{
56
- body: {fontFamily: "text", ...color},
64
+ body: {width: "100%", ...markdownTextStyle},
65
+ bullet_list: {width: "100%"},
66
+ bullet_list_content: {flex: 1, flexShrink: 1, minWidth: 0},
67
+ bullet_list_icon: {
68
+ flexShrink: 0,
69
+ marginLeft: 0,
70
+ marginRight: 8,
71
+ minWidth: 16,
72
+ textAlign: "center",
73
+ ...markdownTextStyle,
74
+ },
57
75
  code_block: {
58
76
  backgroundColor: theme.surface.neutralLight,
59
77
  borderColor: theme.border.default,
@@ -85,13 +103,57 @@ export const MarkdownView: React.FC<{children: React.ReactNode; inverted?: boole
85
103
  padding: 8,
86
104
  ...color,
87
105
  },
88
- heading1: {fontFamily: "heading-bold", fontSize: sizes.xl, ...color},
89
- heading2: {fontFamily: "heading-bold", fontSize: sizes.lg, ...color},
90
- heading3: {fontFamily: "heading-bold", fontSize: sizes.md, ...color},
91
- heading4: {fontFamily: "heading-semibold", fontSize: sizes.sm, ...color},
106
+ heading1: {
107
+ fontFamily: "heading-bold",
108
+ fontSize: sizes.xl,
109
+ lineHeight: sizes.xl * 1.25,
110
+ ...color,
111
+ },
112
+ heading2: {
113
+ fontFamily: "heading-bold",
114
+ fontSize: sizes.lg,
115
+ lineHeight: sizes.lg * 1.25,
116
+ ...color,
117
+ },
118
+ heading3: {
119
+ fontFamily: "heading-bold",
120
+ fontSize: sizes.md,
121
+ lineHeight: sizes.md * 1.25,
122
+ ...color,
123
+ },
124
+ heading4: {
125
+ fontFamily: "heading-semibold",
126
+ fontSize: sizes.sm,
127
+ lineHeight: sizes.sm * 1.25,
128
+ ...color,
129
+ },
92
130
  // h5/h6 map to small as well for consistency, slightly smaller visually handled by weight
93
- heading5: {fontFamily: "heading-semibold", fontSize: sizes.sm, ...color},
94
- heading6: {fontFamily: "heading-semibold", fontSize: sizes.sm, ...color},
131
+ heading5: {
132
+ fontFamily: "heading-semibold",
133
+ fontSize: sizes.sm,
134
+ lineHeight: sizes.sm * 1.25,
135
+ ...color,
136
+ },
137
+ heading6: {
138
+ fontFamily: "heading-semibold",
139
+ fontSize: sizes.sm,
140
+ lineHeight: sizes.sm * 1.25,
141
+ ...color,
142
+ },
143
+ list_item: {alignItems: "flex-start", flexDirection: "row", width: "100%"},
144
+ ordered_list: {width: "100%"},
145
+ ordered_list_content: {flex: 1, flexShrink: 1, minWidth: 0},
146
+ ordered_list_icon: {
147
+ flexShrink: 0,
148
+ marginLeft: 0,
149
+ marginRight: 8,
150
+ minWidth: 32,
151
+ textAlign: "right",
152
+ ...markdownTextStyle,
153
+ },
154
+ paragraph: {flexShrink: 1, width: "100%", ...markdownTextStyle},
155
+ text: color,
156
+ textgroup: {flexShrink: 1, minWidth: 0},
95
157
  }}
96
158
  >
97
159
  {children}
package/src/MediaQuery.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import {Dimensions} from "react-native";
2
2
 
3
- export function mediaQuery(): "xs" | "sm" | "md" | "lg" {
3
+ export const mediaQuery = (): "xs" | "sm" | "md" | "lg" => {
4
4
  const width = Dimensions.get("window").width;
5
5
  if (width < 576) {
6
6
  return "xs";
@@ -11,9 +11,9 @@ export function mediaQuery(): "xs" | "sm" | "md" | "lg" {
11
11
  } else {
12
12
  return "lg";
13
13
  }
14
- }
14
+ };
15
15
 
16
- export function mediaQueryLargerThan(size: "xs" | "sm" | "md" | "lg"): boolean {
16
+ export const mediaQueryLargerThan = (size: "xs" | "sm" | "md" | "lg"): boolean => {
17
17
  const media = mediaQuery();
18
18
  if (size === "xs") {
19
19
  return true;
@@ -25,9 +25,9 @@ export function mediaQueryLargerThan(size: "xs" | "sm" | "md" | "lg"): boolean {
25
25
  return ["lg"].includes(media);
26
26
  }
27
27
  return false;
28
- }
28
+ };
29
29
 
30
- export function mediaQuerySmallerThan(size: "xs" | "sm" | "md" | "lg"): boolean {
30
+ export const mediaQuerySmallerThan = (size: "xs" | "sm" | "md" | "lg"): boolean => {
31
31
  const media = mediaQuery();
32
32
  if (size === "lg") {
33
33
  return true;
@@ -39,8 +39,8 @@ export function mediaQuerySmallerThan(size: "xs" | "sm" | "md" | "lg"): boolean
39
39
  return ["xs"].includes(media);
40
40
  }
41
41
  return false;
42
- }
42
+ };
43
43
 
44
- export function isMobileDevice(): boolean {
44
+ export const isMobileDevice = (): boolean => {
45
45
  return !mediaQueryLargerThan("sm");
46
- }
46
+ };
@@ -1,5 +1,5 @@
1
1
  import {describe, expect, it, mock} from "bun:test";
2
- import {fireEvent} from "@testing-library/react-native";
2
+ import {act, fireEvent} from "@testing-library/react-native";
3
3
  import {forwardRef, useImperativeHandle, useRef} from "react";
4
4
  import {Pressable, Text, View} from "react-native";
5
5
 
@@ -160,7 +160,7 @@ describe("MobileAddressAutocomplete", () => {
160
160
 
161
161
  it("falls back to the TextField and propagates its onChange without an API key", () => {
162
162
  const handleAddressChange = mock(() => {});
163
- const {UNSAFE_root} = renderWithTheme(
163
+ const {root} = renderWithTheme(
164
164
  <MobileAddressAutocomplete
165
165
  handleAddressChange={handleAddressChange}
166
166
  handleAutoCompleteChange={() => {}}
@@ -168,7 +168,11 @@ describe("MobileAddressAutocomplete", () => {
168
168
  testID="mobile-fallback"
169
169
  />
170
170
  );
171
- expect(UNSAFE_root).toBeTruthy();
171
+ // Find the TextField component with nativeID="address1" and trigger its onChange callback
172
+ const textFields = root.findAll((n) => n.props.nativeID === "address1" && n.props.onChangeText);
173
+ expect(textFields.length).toBeGreaterThan(0);
174
+ textFields[0].props.onChangeText("123 Main St");
175
+ expect(handleAddressChange).toHaveBeenCalledWith("123 Main St");
172
176
  });
173
177
 
174
178
  it("wrapping TouchableOpacity clears focus when pressed", () => {
@@ -185,4 +189,23 @@ describe("MobileAddressAutocomplete", () => {
185
189
  expect(wrapper).toBeTruthy();
186
190
  expect(() => wrapper.props.onPress?.()).not.toThrow();
187
191
  });
192
+
193
+ it("fires handleAddressChange from the fallback TextField onChange", () => {
194
+ const handleAddressChange = mock(() => {});
195
+ const {TextField} = require("./TextField") as {
196
+ TextField: React.ComponentType<{onChange?: (v: string) => void}>;
197
+ };
198
+ const {UNSAFE_getByType} = renderWithTheme(
199
+ <MobileAddressAutocomplete
200
+ handleAddressChange={handleAddressChange}
201
+ handleAutoCompleteChange={() => {}}
202
+ inputValue=""
203
+ />
204
+ );
205
+ const textField = UNSAFE_getByType(TextField);
206
+ act(() => {
207
+ textField.props.onChange?.("789 Elm St");
208
+ });
209
+ expect(handleAddressChange).toHaveBeenCalledWith("789 Elm St");
210
+ });
188
211
  });