@terreno/ui 0.14.0 → 0.14.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 (79) hide show
  1. package/dist/ActionSheet.d.ts +1 -1
  2. package/dist/ActionSheet.js +2 -2
  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/MediaQuery.d.ts +4 -4
  13. package/dist/MediaQuery.js +8 -8
  14. package/dist/MediaQuery.js.map +1 -1
  15. package/dist/Page.d.ts +1 -0
  16. package/dist/Page.js +6 -2
  17. package/dist/Page.js.map +1 -1
  18. package/dist/PickerSelect.d.ts +1 -1
  19. package/dist/PickerSelect.js +2 -2
  20. package/dist/PickerSelect.js.map +1 -1
  21. package/dist/TapToEdit.d.ts +1 -1
  22. package/dist/TapToEdit.js +2 -3
  23. package/dist/TapToEdit.js.map +1 -1
  24. package/dist/ToastNotifications.js +2 -2
  25. package/dist/ToastNotifications.js.map +1 -1
  26. package/dist/Tooltip.d.ts +24 -1
  27. package/dist/Tooltip.js +2 -2
  28. package/dist/Tooltip.js.map +1 -1
  29. package/dist/Unifier.d.ts +1 -1
  30. package/dist/Unifier.js +14 -11
  31. package/dist/Unifier.js.map +1 -1
  32. package/dist/Utilities.d.ts +8 -8
  33. package/dist/Utilities.js +12 -14
  34. package/dist/Utilities.js.map +1 -1
  35. package/dist/index.d.ts +1 -1
  36. package/dist/index.js +1 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/signUp/PasswordRequirements.js +3 -3
  39. package/dist/signUp/PasswordRequirements.js.map +1 -1
  40. package/dist/table/TableHeaderCell.js +1 -9
  41. package/dist/table/TableHeaderCell.js.map +1 -1
  42. package/dist/table/tableContext.d.ts +1 -1
  43. package/dist/table/tableContext.js +2 -2
  44. package/dist/table/tableContext.js.map +1 -1
  45. package/package.json +1 -1
  46. package/src/ActionSheet.tsx +2 -2
  47. package/src/Banner.test.tsx +71 -0
  48. package/src/Common.ts +10 -4
  49. package/src/ConsentFormScreen.test.tsx +22 -0
  50. package/src/ConsentFormScreen.tsx +9 -3
  51. package/src/DataTable.test.tsx +217 -0
  52. package/src/DateUtilities.tsx +37 -38
  53. package/src/HeightActionSheet.test.tsx +16 -0
  54. package/src/HeightField.test.tsx +106 -1
  55. package/src/MediaQuery.ts +8 -8
  56. package/src/MobileAddressAutoComplete.test.tsx +20 -1
  57. package/src/Page.test.tsx +28 -0
  58. package/src/Page.tsx +17 -2
  59. package/src/PickerSelect.tsx +3 -3
  60. package/src/TapToEdit.test.tsx +31 -0
  61. package/src/TapToEdit.tsx +2 -3
  62. package/src/ToastNotifications.test.tsx +738 -0
  63. package/src/ToastNotifications.tsx +2 -2
  64. package/src/Tooltip.test.tsx +587 -2
  65. package/src/Tooltip.tsx +2 -2
  66. package/src/Unifier.ts +14 -11
  67. package/src/Utilities.tsx +14 -16
  68. package/src/WebAddressAutocomplete.test.tsx +138 -0
  69. package/src/WebDropdownMenu.test.tsx +23 -0
  70. package/src/index.tsx +1 -1
  71. package/src/login/LoginScreen.test.tsx +23 -1
  72. package/src/signUp/PasswordRequirements.tsx +9 -6
  73. package/src/signUp/__snapshots__/PasswordRequirements.test.tsx.snap +50 -2
  74. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +25 -1
  75. package/src/table/TableHeaderCell.tsx +8 -11
  76. package/src/table/TableRow.test.tsx +31 -1
  77. package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +2 -0
  78. package/src/table/tableContext.tsx +2 -2
  79. package/src/useStoredState.test.tsx +47 -0
package/src/Page.test.tsx CHANGED
@@ -2,6 +2,7 @@ import {afterAll, describe, expect, it, mock} from "bun:test";
2
2
  import {act, fireEvent, waitFor} from "@testing-library/react-native";
3
3
  import React, {type ReactNode} from "react";
4
4
  import {Pressable, Text as RNText} from "react-native";
5
+ import {SafeAreaView} from "react-native-safe-area-context";
5
6
 
6
7
  // Override the IconButton mock so the inline onClick arrows fire when pressed.
7
8
  mock.module("./IconButton", () => ({
@@ -273,6 +274,33 @@ describe("Page", () => {
273
274
  expect(routerBack).toHaveBeenCalled();
274
275
  });
275
276
 
277
+ it("wraps content in SafeAreaView when safeArea is true", () => {
278
+ const {UNSAFE_root} = renderWithTheme(
279
+ <Page navigation={mockNavigation} safeArea>
280
+ <Text>Content</Text>
281
+ </Page>
282
+ );
283
+ expect(UNSAFE_root.findAllByType(SafeAreaView).length).toBeGreaterThan(0);
284
+ });
285
+
286
+ it("does not wrap content in SafeAreaView when safeArea is omitted", () => {
287
+ const {UNSAFE_root} = renderWithTheme(
288
+ <Page navigation={mockNavigation}>
289
+ <Text>Content</Text>
290
+ </Page>
291
+ );
292
+ expect(UNSAFE_root.findAllByType(SafeAreaView)).toHaveLength(0);
293
+ });
294
+
295
+ it("does not wrap content in SafeAreaView when safeArea is false", () => {
296
+ const {UNSAFE_root} = renderWithTheme(
297
+ <Page navigation={mockNavigation} safeArea={false}>
298
+ <Text>Content</Text>
299
+ </Page>
300
+ );
301
+ expect(UNSAFE_root.findAllByType(SafeAreaView)).toHaveLength(0);
302
+ });
303
+
276
304
  it("safely handles a missing rightButtonOnClick callback", async () => {
277
305
  const {getByText} = renderWithTheme(
278
306
  <Page navigation={mockNavigation} rightButton="Go" title="Page">
package/src/Page.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import {router} from "expo-router";
2
2
  import React from "react";
3
+ import {SafeAreaView} from "react-native-safe-area-context";
3
4
 
4
5
  import {Box} from "./Box";
5
6
  import {Button} from "./Button";
@@ -58,9 +59,9 @@ export class Page extends React.Component<PageProps, {}> {
58
59
  );
59
60
  }
60
61
 
61
- render() {
62
+ renderBody() {
62
63
  return (
63
- <ErrorBoundary onError={this.props.onError}>
64
+ <>
64
65
  <Box
65
66
  alignSelf="center"
66
67
  avoidKeyboard
@@ -112,6 +113,20 @@ export class Page extends React.Component<PageProps, {}> {
112
113
  {this.props.footer}
113
114
  </Box>
114
115
  )}
116
+ </>
117
+ );
118
+ }
119
+
120
+ render() {
121
+ return (
122
+ <ErrorBoundary onError={this.props.onError}>
123
+ {this.props.safeArea ? (
124
+ <SafeAreaView edges={["top", "bottom"]} style={{flex: 1}}>
125
+ {this.renderBody()}
126
+ </SafeAreaView>
127
+ ) : (
128
+ this.renderBody()
129
+ )}
115
130
  </ErrorBoundary>
116
131
  );
117
132
  }
@@ -114,7 +114,7 @@ export interface RNPickerSelectProps {
114
114
  InputAccessoryView?: ComponentType<{testID?: string}>;
115
115
  }
116
116
 
117
- export function RNPickerSelect({
117
+ export const RNPickerSelect = ({
118
118
  onValueChange,
119
119
  value,
120
120
  items,
@@ -136,7 +136,7 @@ export function RNPickerSelect({
136
136
  touchableWrapperProps,
137
137
 
138
138
  InputAccessoryView,
139
- }: RNPickerSelectProps) {
139
+ }: RNPickerSelectProps) => {
140
140
  const [showPicker, setShowPicker] = useState<boolean>(false);
141
141
  const [animationType, setAnimationType] = useState<ModalProps["animationType"]>(undefined);
142
142
  const [orientation, setOrientation] = useState<"portrait" | "landscape">("portrait");
@@ -683,4 +683,4 @@ export function RNPickerSelect({
683
683
  };
684
684
 
685
685
  return render();
686
- }
686
+ };
@@ -332,3 +332,34 @@ describe("formatAddress", () => {
332
332
  expect(result).toContain("(113)");
333
333
  });
334
334
  });
335
+
336
+ describe("TapToEdit - additional function coverage", () => {
337
+ it("shows Clear button for date type and invokes setValue and onSave", async () => {
338
+ const setValue = mock(() => {});
339
+ const onSave = mock(() => Promise.resolve());
340
+ const {getByLabelText, getByText} = renderWithTheme(
341
+ <TapToEdit onSave={onSave} setValue={setValue} title="Date" type="date" value="2024-01-01" />
342
+ );
343
+ await act(async () => {
344
+ fireEvent.press(getByLabelText("Edit"));
345
+ });
346
+ expect(getByText("Clear")).toBeTruthy();
347
+ await act(async () => {
348
+ fireEvent.press(getByText("Clear"));
349
+ await new Promise((resolve) => setTimeout(resolve, 600));
350
+ });
351
+ expect(setValue).toHaveBeenCalledWith("");
352
+ expect(onSave).toHaveBeenCalledWith("");
353
+ });
354
+
355
+ it("assigns inputRef for text type in editing mode", async () => {
356
+ const setValue = mock(() => {});
357
+ const {getByLabelText, queryByText} = renderWithTheme(
358
+ <TapToEdit setValue={setValue} title="Name" type="text" value="Alice" />
359
+ );
360
+ await act(async () => {
361
+ fireEvent.press(getByLabelText("Edit"));
362
+ });
363
+ expect(queryByText("Save")).toBeTruthy();
364
+ });
365
+ });
package/src/TapToEdit.tsx CHANGED
@@ -26,7 +26,7 @@ const TapToEditTitle: FC<{
26
26
  );
27
27
  };
28
28
 
29
- export function formatAddress(address: AddressInterface, asString = false): string {
29
+ export const formatAddress = (address: AddressInterface, asString = false): string => {
30
30
  let city = "";
31
31
  if (address?.city) {
32
32
  city = address?.state || address.zipcode ? `${address.city}, ` : `${address.city}`;
@@ -49,7 +49,6 @@ export function formatAddress(address: AddressInterface, asString = false): stri
49
49
  const addressLineFour = `${countyName}${address?.countyCode ? ` (${countyCode})` : ""}`;
50
50
 
51
51
  if (!asString) {
52
- // Only add new lines if lines before and after are not empty to avoid awkward whitespace
53
52
  return `${addressLineOne}${
54
53
  addressLineOne && (addressLineTwo || addressLineThree) ? `\n` : ""
55
54
  }${addressLineTwo}${addressLineTwo && addressLineThree ? `\n` : ""}${addressLineThree}${
@@ -62,7 +61,7 @@ export function formatAddress(address: AddressInterface, asString = false): stri
62
61
  addressLineThree && addressLineFour ? `, ` : ""
63
62
  }${addressLineFour}`;
64
63
  }
65
- }
64
+ };
66
65
 
67
66
  export const TapToEdit: FC<TapToEditProps> = ({
68
67
  value,