@jobber/components-native 0.89.5-JOB-140604-2d32fc8.44 → 0.89.5-JOB-140604-8777ec5.52

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 (229) hide show
  1. package/dist/package.json +7 -7
  2. package/dist/src/ActionItem/ActionItemGroup.js +1 -1
  3. package/dist/src/AutoLink/components/Link/Link.js +1 -1
  4. package/dist/src/BottomSheet/BottomSheet.js +4 -2
  5. package/dist/src/BottomSheet/hooks/useBottomSheetBackHandler.js +26 -0
  6. package/dist/src/Chip/Chip.js +12 -1
  7. package/dist/src/Chip/Chip.style.js +1 -1
  8. package/dist/src/ContentOverlay/ContentOverlay.js +3 -5
  9. package/dist/src/ErrorMessageWrapper/context/ErrorMessageProvider.js +1 -1
  10. package/dist/src/Form/Form.js +2 -1
  11. package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.js +1 -1
  12. package/dist/src/Form/hooks/useInternalForm.js +6 -3
  13. package/dist/src/FormatFile/components/MediaView/MediaView.js +22 -5
  14. package/dist/src/InputDate/InputDate.js +2 -2
  15. package/dist/src/InputFieldWrapper/InputFieldWrapper.js +14 -12
  16. package/dist/src/InputFieldWrapper/components/Prefix/Prefix.js +5 -2
  17. package/dist/src/InputFieldWrapper/components/Suffix/Suffix.js +5 -2
  18. package/dist/src/InputPressable/InputPressable.js +20 -8
  19. package/dist/src/InputPressable/InputPressable.style.js +3 -0
  20. package/dist/src/InputText/InputText.js +22 -11
  21. package/dist/src/InputText/InputText.style.js +4 -0
  22. package/dist/src/InputTime/InputTime.js +2 -2
  23. package/dist/src/Menu/Menu.js +2 -2
  24. package/dist/src/Select/components/SelectPressable/SelectPressable.js +1 -1
  25. package/dist/src/utils/meta/meta.json +0 -1
  26. package/dist/tsconfig.build.tsbuildinfo +1 -1
  27. package/dist/types/src/ActionItem/ActionItem.d.ts +2 -1
  28. package/dist/types/src/ActionItem/ActionItemGroup.d.ts +2 -1
  29. package/dist/types/src/ActionItem/components/ActionItemContainer.d.ts +2 -1
  30. package/dist/types/src/ActionLabel/ActionLabel.d.ts +1 -1
  31. package/dist/types/src/ActivityIndicator/ActivityIndicator.d.ts +2 -1
  32. package/dist/types/src/AutoLink/AutoLink.d.ts +2 -1
  33. package/dist/types/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.d.ts +2 -1
  34. package/dist/types/src/AutoLink/components/Link/Link.d.ts +2 -1
  35. package/dist/types/src/Banner/Banner.d.ts +2 -1
  36. package/dist/types/src/Banner/components/BannerIcon/BannerIcon.d.ts +2 -1
  37. package/dist/types/src/BottomSheet/BottomSheet.d.ts +4 -9
  38. package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.d.ts +2 -1
  39. package/dist/types/src/BottomSheet/hooks/useBottomSheetBackHandler.d.ts +8 -0
  40. package/dist/types/src/Button/Button.d.ts +2 -1
  41. package/dist/types/src/Button/components/InternalButtonLoading/InternalButtonLoading.d.ts +1 -1
  42. package/dist/types/src/ButtonGroup/ButtonGroup.d.ts +2 -1
  43. package/dist/types/src/ButtonGroup/ButtonGroupAction.d.ts +4 -3
  44. package/dist/types/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.d.ts +3 -2
  45. package/dist/types/src/Card/Card.d.ts +2 -1
  46. package/dist/types/src/Card/components/InternalCardHeader.d.ts +2 -1
  47. package/dist/types/src/Checkbox/Checkbox.d.ts +2 -1
  48. package/dist/types/src/Checkbox/CheckboxGroup.d.ts +2 -1
  49. package/dist/types/src/Chip/Chip.d.ts +2 -1
  50. package/dist/types/src/Content/Content.d.ts +2 -1
  51. package/dist/types/src/ContentOverlay/UNSAFE_WrappedModalize.d.ts +1 -1
  52. package/dist/types/src/Disclosure/Disclosure.d.ts +1 -1
  53. package/dist/types/src/Divider/Divider.d.ts +2 -1
  54. package/dist/types/src/EmptyState/EmptyState.d.ts +2 -1
  55. package/dist/types/src/ErrorMessageWrapper/ErrorMessageWrapper.d.ts +2 -1
  56. package/dist/types/src/ErrorMessageWrapper/context/ErrorMessageProvider.d.ts +2 -1
  57. package/dist/types/src/ErrorMessageWrapper/context/types.d.ts +1 -1
  58. package/dist/types/src/Flex/Flex.d.ts +2 -1
  59. package/dist/types/src/Form/Form.d.ts +2 -1
  60. package/dist/types/src/Form/components/FormActionBar/FormActionBar.d.ts +3 -2
  61. package/dist/types/src/Form/components/FormBody/FormBody.d.ts +3 -2
  62. package/dist/types/src/Form/components/FormCache/FormCache.d.ts +2 -1
  63. package/dist/types/src/Form/components/FormErrorBanner/FormErrorBanner.d.ts +2 -1
  64. package/dist/types/src/Form/components/FormMask/FormMask.d.ts +2 -1
  65. package/dist/types/src/Form/components/FormMessage/FormMessage.d.ts +2 -1
  66. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.d.ts +2 -1
  67. package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.d.ts +2 -1
  68. package/dist/types/src/Form/components/FormSaveButton/FormSaveButton.d.ts +2 -1
  69. package/dist/types/src/Form/context/AtlantisFormContext.d.ts +1 -1
  70. package/dist/types/src/Form/context/types.d.ts +2 -2
  71. package/dist/types/src/Form/hooks/useFormViewRefs.d.ts +2 -2
  72. package/dist/types/src/Form/hooks/useInternalForm.d.ts +5 -5
  73. package/dist/types/src/Form/types.d.ts +10 -4
  74. package/dist/types/src/FormField/FormField.d.ts +1 -1
  75. package/dist/types/src/FormatFile/FormatFile.d.ts +2 -1
  76. package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.d.ts +2 -1
  77. package/dist/types/src/FormatFile/components/FileView/FileView.d.ts +2 -1
  78. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.d.ts +3 -2
  79. package/dist/types/src/FormatFile/components/MediaView/MediaView.d.ts +2 -1
  80. package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.d.ts +2 -1
  81. package/dist/types/src/Heading/Heading.d.ts +1 -1
  82. package/dist/types/src/Icon/Icon.d.ts +2 -1
  83. package/dist/types/src/IconButton/IconButton.d.ts +1 -1
  84. package/dist/types/src/InputCurrency/InputCurrency.d.ts +2 -1
  85. package/dist/types/src/InputDate/InputDate.d.ts +4 -2
  86. package/dist/types/src/InputFieldWrapper/InputFieldWrapper.d.ts +9 -2
  87. package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.d.ts +2 -1
  88. package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.d.ts +4 -4
  89. package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.d.ts +4 -4
  90. package/dist/types/src/InputPressable/InputPressable.d.ts +9 -1
  91. package/dist/types/src/InputPressable/InputPressable.style.d.ts +3 -0
  92. package/dist/types/src/InputSearch/InputSearch.d.ts +1 -1
  93. package/dist/types/src/InputSearch/components/FilterButton.d.ts +2 -1
  94. package/dist/types/src/InputText/InputText.d.ts +8 -0
  95. package/dist/types/src/InputText/InputText.style.d.ts +4 -0
  96. package/dist/types/src/InputText/context/InputAccessoriesProvider.d.ts +2 -1
  97. package/dist/types/src/InputTime/InputTime.d.ts +4 -2
  98. package/dist/types/src/Menu/Menu.d.ts +2 -1
  99. package/dist/types/src/Menu/components/MenuOption/MenuOption.d.ts +2 -1
  100. package/dist/types/src/Menu/components/Overlay/Overlay.d.ts +2 -1
  101. package/dist/types/src/Menu/types.d.ts +6 -1
  102. package/dist/types/src/ProgressBar/ProgressBar.d.ts +2 -1
  103. package/dist/types/src/ProgressBar/ProgressBarInner.d.ts +2 -1
  104. package/dist/types/src/Select/Select.d.ts +3 -2
  105. package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.d.ts +2 -1
  106. package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.d.ts +2 -1
  107. package/dist/types/src/Select/components/SelectInternalPicker/SelectInternalPicker.d.ts +2 -1
  108. package/dist/types/src/Select/components/SelectPressable/SelectPressable.d.ts +2 -1
  109. package/dist/types/src/StatusLabel/StatusLabel.d.ts +2 -1
  110. package/dist/types/src/Switch/Switch.d.ts +2 -1
  111. package/dist/types/src/Switch/components/BaseSwitch/BaseSwitch.d.ts +2 -1
  112. package/dist/types/src/Text/Text.d.ts +1 -1
  113. package/dist/types/src/TextList/TextList.d.ts +2 -1
  114. package/dist/types/src/ThumbnailList/ThumbnailList.d.ts +2 -1
  115. package/dist/types/src/Toast/Toast.d.ts +2 -1
  116. package/dist/types/src/Typography/Typography.d.ts +1 -1
  117. package/dist/types/src/Typography/TypographyGestureDetector.d.ts +2 -1
  118. package/dist/types/src/utils/test/MockSafeAreaProvider.d.ts +1 -1
  119. package/package.json +7 -7
  120. package/src/ActionItem/ActionItem.tsx +1 -1
  121. package/src/ActionItem/ActionItemGroup.tsx +1 -3
  122. package/src/ActionItem/components/ActionItemContainer.tsx +1 -1
  123. package/src/ActionLabel/ActionLabel.tsx +1 -1
  124. package/src/ActivityIndicator/ActivityIndicator.tsx +1 -3
  125. package/src/AutoLink/AutoLink.tsx +1 -1
  126. package/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.tsx +1 -1
  127. package/src/AutoLink/components/Link/Link.tsx +1 -5
  128. package/src/Banner/Banner.tsx +2 -2
  129. package/src/Banner/components/BannerIcon/BannerIcon.tsx +1 -1
  130. package/src/BottomSheet/BottomSheet.stories.tsx +0 -1
  131. package/src/BottomSheet/BottomSheet.tsx +9 -10
  132. package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.tsx +1 -1
  133. package/src/BottomSheet/hooks/useBottomSheetBackHandler.test.ts +90 -0
  134. package/src/BottomSheet/hooks/useBottomSheetBackHandler.ts +41 -0
  135. package/src/Button/Button.tsx +1 -1
  136. package/src/Button/components/InternalButtonLoading/InternalButtonLoading.tsx +1 -1
  137. package/src/ButtonGroup/ButtonGroup.tsx +1 -1
  138. package/src/ButtonGroup/ButtonGroupAction.tsx +4 -4
  139. package/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.tsx +2 -2
  140. package/src/Card/Card.tsx +1 -1
  141. package/src/Card/components/InternalCardHeader.tsx +1 -1
  142. package/src/Checkbox/Checkbox.tsx +2 -2
  143. package/src/Checkbox/CheckboxGroup.test.tsx +1 -1
  144. package/src/Checkbox/CheckboxGroup.tsx +2 -2
  145. package/src/Chip/Chip.style.ts +1 -1
  146. package/src/Chip/Chip.tsx +20 -2
  147. package/src/Content/Content.tsx +1 -1
  148. package/src/ContentOverlay/ContentOverlay.tsx +3 -4
  149. package/src/Disclosure/Disclosure.tsx +1 -1
  150. package/src/Divider/Divider.tsx +1 -1
  151. package/src/EmptyState/EmptyState.tsx +1 -1
  152. package/src/ErrorMessageWrapper/ErrorMessageWrapper.tsx +1 -1
  153. package/src/ErrorMessageWrapper/context/ErrorMessageProvider.tsx +3 -5
  154. package/src/ErrorMessageWrapper/context/types.ts +1 -1
  155. package/src/Flex/Flex.tsx +2 -2
  156. package/src/Form/Form.test.tsx +145 -2
  157. package/src/Form/Form.tsx +3 -1
  158. package/src/Form/components/FormActionBar/FormActionBar.tsx +3 -3
  159. package/src/Form/components/FormBody/FormBody.tsx +3 -3
  160. package/src/Form/components/FormCache/FormCache.tsx +1 -1
  161. package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +1 -1
  162. package/src/Form/components/FormMask/FormMask.tsx +1 -1
  163. package/src/Form/components/FormMessage/FormMessage.tsx +1 -1
  164. package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +1 -1
  165. package/src/Form/components/FormMessageBanner/FormMessageBanner.tsx +1 -3
  166. package/src/Form/components/FormSaveButton/FormSaveButton.tsx +1 -1
  167. package/src/Form/context/types.ts +2 -2
  168. package/src/Form/hooks/useFormViewRefs.ts +4 -5
  169. package/src/Form/hooks/useInternalForm.ts +12 -5
  170. package/src/Form/types.ts +11 -4
  171. package/src/FormField/FormField.tsx +1 -1
  172. package/src/FormatFile/FormatFile.tsx +3 -3
  173. package/src/FormatFile/components/ErrorIcon/ErrorIcon.tsx +1 -1
  174. package/src/FormatFile/components/FileView/FileView.tsx +1 -1
  175. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +2 -2
  176. package/src/FormatFile/components/MediaView/MediaView.test.tsx +283 -0
  177. package/src/FormatFile/components/MediaView/MediaView.tsx +28 -7
  178. package/src/FormatFile/components/ProgressBar/ProgressBar.tsx +1 -1
  179. package/src/Heading/Heading.tsx +1 -1
  180. package/src/Icon/Icon.tsx +1 -1
  181. package/src/IconButton/IconButton.tsx +1 -1
  182. package/src/InputCurrency/InputCurrency.tsx +1 -1
  183. package/src/InputDate/InputDate.tsx +7 -3
  184. package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +48 -1
  185. package/src/InputFieldWrapper/InputFieldWrapper.tsx +39 -29
  186. package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +1 -1
  187. package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +3 -5
  188. package/src/InputFieldWrapper/components/Prefix/Prefix.tsx +8 -6
  189. package/src/InputFieldWrapper/components/Suffix/Suffix.test.tsx +2 -4
  190. package/src/InputFieldWrapper/components/Suffix/Suffix.tsx +8 -6
  191. package/src/InputPassword/InputPassword.tsx +1 -1
  192. package/src/InputPressable/InputPressable.style.ts +4 -0
  193. package/src/InputPressable/InputPressable.test.tsx +75 -1
  194. package/src/InputPressable/InputPressable.tsx +34 -8
  195. package/src/InputSearch/InputSearch.tsx +1 -0
  196. package/src/InputSearch/components/FilterButton.tsx +1 -1
  197. package/src/InputText/InputText.style.ts +5 -0
  198. package/src/InputText/InputText.test.tsx +75 -0
  199. package/src/InputText/InputText.tsx +32 -12
  200. package/src/InputText/context/InputAccessoriesProvider.tsx +1 -1
  201. package/src/InputTime/InputTime.tsx +7 -3
  202. package/src/Menu/Menu.tsx +3 -3
  203. package/src/Menu/components/MenuOption/MenuOption.tsx +1 -1
  204. package/src/Menu/components/Overlay/Overlay.tsx +1 -1
  205. package/src/Menu/types.ts +7 -1
  206. package/src/ProgressBar/ProgressBar.tsx +1 -1
  207. package/src/ProgressBar/ProgressBarInner.tsx +1 -1
  208. package/src/Select/Select.tsx +2 -2
  209. package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.tsx +1 -1
  210. package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.tsx +1 -1
  211. package/src/Select/components/SelectInternalPicker/SelectInternalPicker.tsx +1 -1
  212. package/src/Select/components/SelectPressable/SelectPressable.tsx +1 -4
  213. package/src/StatusLabel/StatusLabel.tsx +1 -1
  214. package/src/Switch/Switch.tsx +1 -1
  215. package/src/Switch/components/BaseSwitch/BaseSwitch.tsx +1 -1
  216. package/src/Text/Text.tsx +1 -1
  217. package/src/TextList/TextList.tsx +1 -1
  218. package/src/ThumbnailList/ThumbnailList.tsx +1 -1
  219. package/src/Toast/Toast.tsx +2 -2
  220. package/src/Typography/Typography.tsx +1 -1
  221. package/src/Typography/TypographyGestureDetector.tsx +1 -3
  222. package/src/utils/meta/meta.json +0 -1
  223. package/src/utils/test/MockSafeAreaProvider.tsx +1 -1
  224. package/dist/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.js +0 -45
  225. package/dist/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.styles.js +0 -8
  226. package/dist/types/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.d.ts +0 -9
  227. package/dist/types/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.styles.d.ts +0 -5
  228. package/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.styles.ts +0 -9
  229. package/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.tsx +0 -89
@@ -0,0 +1,283 @@
1
+ import React from "react";
2
+ import { fireEvent, render, waitFor } from "@testing-library/react-native";
3
+ import { MediaView } from "./MediaView";
4
+ import type { FormattedFile } from "../../types";
5
+ import { StatusCode } from "../../types";
6
+ import { AtlantisFormatFileContext } from "../../context/FormatFileContext";
7
+
8
+ jest.mock("../../../hooks/useAtlantisI18n", () => ({
9
+ useAtlantisI18n: () => ({ t: (key: string) => key }),
10
+ }));
11
+
12
+ describe("MediaView", () => {
13
+ const mockFile: FormattedFile = {
14
+ showPreview: true,
15
+ source: "https://example.com/image1.jpg",
16
+ thumbnailUrl: undefined,
17
+ name: "test.jpg",
18
+ size: 1024,
19
+ external: false,
20
+ progress: 0,
21
+ status: StatusCode.Completed,
22
+ error: false,
23
+ type: "image/jpeg",
24
+ isMedia: true,
25
+ showFileTypeIndicator: false,
26
+ };
27
+
28
+ const defaultProps = {
29
+ accessibilityLabel: "Test image",
30
+ showOverlay: false,
31
+ showError: false,
32
+ file: mockFile,
33
+ styleInGrid: false,
34
+ onUploadComplete: jest.fn(),
35
+ };
36
+
37
+ const mockContextValue = {
38
+ useCreateThumbnail: () => ({ thumbnail: undefined, error: false }),
39
+ };
40
+
41
+ const renderWithContext = (props = defaultProps) => {
42
+ return render(
43
+ <AtlantisFormatFileContext.Provider value={mockContextValue}>
44
+ <MediaView {...props} />
45
+ </AtlantisFormatFileContext.Provider>,
46
+ );
47
+ };
48
+
49
+ describe("Normal loading flow", () => {
50
+ it("shows loading indicator when onLoadStart fires", () => {
51
+ const { getByTestId, queryByTestId } = renderWithContext();
52
+ const image = getByTestId("test-image");
53
+
54
+ expect(queryByTestId("ActivityIndicator")).toBeNull();
55
+
56
+ fireEvent(image, "loadStart");
57
+
58
+ expect(queryByTestId("ActivityIndicator")).toBeTruthy();
59
+ });
60
+
61
+ it("hides loading indicator when onLoadEnd fires", () => {
62
+ const { getByTestId, queryByTestId } = renderWithContext();
63
+ const image = getByTestId("test-image");
64
+
65
+ fireEvent(image, "loadStart");
66
+ expect(queryByTestId("ActivityIndicator")).toBeTruthy();
67
+
68
+ fireEvent(image, "loadEnd");
69
+
70
+ expect(queryByTestId("ActivityIndicator")).toBeNull();
71
+ });
72
+ });
73
+
74
+ describe("Race condition handling (cached images)", () => {
75
+ it("does not get stuck loading when onLoadEnd fires before onLoadStart", () => {
76
+ const { getByTestId, queryByTestId } = renderWithContext();
77
+ const image = getByTestId("test-image");
78
+
79
+ // Simulate cached image: LoadEnd fires BEFORE LoadStart
80
+ fireEvent(image, "loadEnd");
81
+ expect(queryByTestId("ActivityIndicator")).toBeNull();
82
+
83
+ fireEvent(image, "loadStart");
84
+
85
+ expect(queryByTestId("ActivityIndicator")).toBeNull();
86
+ });
87
+
88
+ it("does not show infinite spinner when load events fire out of order", () => {
89
+ const { getByTestId, queryByTestId } = renderWithContext();
90
+ const image = getByTestId("test-image");
91
+
92
+ // Race condition scenario
93
+ fireEvent(image, "loadEnd");
94
+ fireEvent(image, "loadStart");
95
+ fireEvent(image, "loadEnd");
96
+
97
+ expect(queryByTestId("ActivityIndicator")).toBeNull();
98
+ });
99
+ });
100
+
101
+ describe("URI changes", () => {
102
+ it("shows loading indicator when URI changes to a new image", async () => {
103
+ const { getByTestId, queryByTestId, rerender } = renderWithContext();
104
+ const image = getByTestId("test-image");
105
+
106
+ // First image: simulate cached load (LoadEnd before LoadStart)
107
+ fireEvent(image, "loadEnd");
108
+ fireEvent(image, "loadStart");
109
+ expect(queryByTestId("ActivityIndicator")).toBeNull();
110
+
111
+ // Change URI to a new image
112
+ const newFile = {
113
+ ...mockFile,
114
+ source: "https://example.com/image2.jpg",
115
+ };
116
+
117
+ rerender(
118
+ <AtlantisFormatFileContext.Provider value={mockContextValue}>
119
+ <MediaView {...defaultProps} file={newFile} />
120
+ </AtlantisFormatFileContext.Provider>,
121
+ );
122
+
123
+ await waitFor(() => {
124
+ const updatedImage = getByTestId("test-image");
125
+
126
+ // New image starts loading
127
+ fireEvent(updatedImage, "loadStart");
128
+
129
+ expect(queryByTestId("ActivityIndicator")).toBeTruthy();
130
+ });
131
+ });
132
+
133
+ it("shows loading indicator on second URI change", async () => {
134
+ const { getByTestId, queryByTestId, rerender } = renderWithContext();
135
+
136
+ const image1 = getByTestId("test-image");
137
+ fireEvent(image1, "loadStart");
138
+ fireEvent(image1, "loadEnd");
139
+ expect(queryByTestId("ActivityIndicator")).toBeNull();
140
+
141
+ const file2 = { ...mockFile, source: "https://example.com/image2.jpg" };
142
+ rerender(
143
+ <AtlantisFormatFileContext.Provider value={mockContextValue}>
144
+ <MediaView {...defaultProps} file={file2} />
145
+ </AtlantisFormatFileContext.Provider>,
146
+ );
147
+
148
+ await waitFor(() => {
149
+ const image2 = getByTestId("test-image");
150
+ fireEvent(image2, "loadStart");
151
+
152
+ expect(queryByTestId("ActivityIndicator")).toBeTruthy();
153
+ });
154
+ });
155
+
156
+ it("shows loading indicator on third URI change", async () => {
157
+ const { getByTestId, queryByTestId, rerender } = renderWithContext();
158
+
159
+ const image1 = getByTestId("test-image");
160
+ fireEvent(image1, "loadStart");
161
+ fireEvent(image1, "loadEnd");
162
+
163
+ const file2 = { ...mockFile, source: "https://example.com/image2.jpg" };
164
+ rerender(
165
+ <AtlantisFormatFileContext.Provider value={mockContextValue}>
166
+ <MediaView {...defaultProps} file={file2} />
167
+ </AtlantisFormatFileContext.Provider>,
168
+ );
169
+ const image2 = getByTestId("test-image");
170
+ fireEvent(image2, "loadEnd");
171
+
172
+ const file3 = { ...mockFile, source: "https://example.com/image3.jpg" };
173
+ rerender(
174
+ <AtlantisFormatFileContext.Provider value={mockContextValue}>
175
+ <MediaView {...defaultProps} file={file3} />
176
+ </AtlantisFormatFileContext.Provider>,
177
+ );
178
+
179
+ await waitFor(() => {
180
+ const image3 = getByTestId("test-image");
181
+ fireEvent(image3, "loadStart");
182
+
183
+ expect(queryByTestId("ActivityIndicator")).toBeTruthy();
184
+ });
185
+ });
186
+
187
+ it("handles URI change from cached to uncached image correctly", async () => {
188
+ const { getByTestId, queryByTestId, rerender } = renderWithContext();
189
+
190
+ // First image: cached (LoadEnd before LoadStart)
191
+ const image1 = getByTestId("test-image");
192
+ fireEvent(image1, "loadEnd");
193
+ fireEvent(image1, "loadStart");
194
+ expect(queryByTestId("ActivityIndicator")).toBeNull();
195
+
196
+ // Second image: uncached (normal LoadStart then LoadEnd)
197
+ const file2 = { ...mockFile, source: "https://example.com/image2.jpg" };
198
+ rerender(
199
+ <AtlantisFormatFileContext.Provider value={mockContextValue}>
200
+ <MediaView {...defaultProps} file={file2} />
201
+ </AtlantisFormatFileContext.Provider>,
202
+ );
203
+
204
+ await waitFor(() => {
205
+ const image2 = getByTestId("test-image");
206
+ fireEvent(image2, "loadStart");
207
+
208
+ expect(queryByTestId("ActivityIndicator")).toBeTruthy();
209
+
210
+ fireEvent(image2, "loadEnd");
211
+ expect(queryByTestId("ActivityIndicator")).toBeNull();
212
+ });
213
+ });
214
+ });
215
+
216
+ describe("thumbnailUrl changes", () => {
217
+ it("shows loading indicator when thumbnailUrl changes", async () => {
218
+ const { getByTestId, queryByTestId, rerender } = renderWithContext();
219
+
220
+ // First load completes
221
+ const image1 = getByTestId("test-image");
222
+ fireEvent(image1, "loadStart");
223
+ fireEvent(image1, "loadEnd");
224
+ expect(queryByTestId("ActivityIndicator")).toBeNull();
225
+
226
+ // Thumbnail URL changes (common when thumbnail generation completes)
227
+ const fileWithThumbnail = {
228
+ ...mockFile,
229
+ thumbnailUrl: "https://example.com/thumbnail.jpg",
230
+ };
231
+
232
+ rerender(
233
+ <AtlantisFormatFileContext.Provider value={mockContextValue}>
234
+ <MediaView {...defaultProps} file={fileWithThumbnail} />
235
+ </AtlantisFormatFileContext.Provider>,
236
+ );
237
+
238
+ await waitFor(() => {
239
+ const image2 = getByTestId("test-image");
240
+ fireEvent(image2, "loadStart");
241
+
242
+ expect(queryByTestId("ActivityIndicator")).toBeTruthy();
243
+ });
244
+ });
245
+ });
246
+
247
+ describe("Context thumbnail changes", () => {
248
+ it("shows loading indicator when context thumbnail changes", async () => {
249
+ const mockContextWithThumbnail = {
250
+ useCreateThumbnail: () => ({
251
+ thumbnail: "https://example.com/context-thumbnail.jpg",
252
+ error: false,
253
+ }),
254
+ };
255
+
256
+ const { getByTestId, queryByTestId, rerender } = render(
257
+ <AtlantisFormatFileContext.Provider value={mockContextValue}>
258
+ <MediaView {...defaultProps} />
259
+ </AtlantisFormatFileContext.Provider>,
260
+ );
261
+
262
+ // First load completes
263
+ const image1 = getByTestId("test-image");
264
+ fireEvent(image1, "loadStart");
265
+ fireEvent(image1, "loadEnd");
266
+ expect(queryByTestId("ActivityIndicator")).toBeNull();
267
+
268
+ // Context provides a new thumbnail
269
+ rerender(
270
+ <AtlantisFormatFileContext.Provider value={mockContextWithThumbnail}>
271
+ <MediaView {...defaultProps} />
272
+ </AtlantisFormatFileContext.Provider>,
273
+ );
274
+
275
+ await waitFor(() => {
276
+ const image2 = getByTestId("test-image");
277
+ fireEvent(image2, "loadStart");
278
+
279
+ expect(queryByTestId("ActivityIndicator")).toBeTruthy();
280
+ });
281
+ });
282
+ });
283
+ });
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { useEffect, useRef, useState } from "react";
2
2
  import { ImageBackground, View } from "react-native";
3
3
  import { useStyles } from "./MediaView.style";
4
4
  import type { FormattedFile } from "../../types";
@@ -27,11 +27,17 @@ export function MediaView({
27
27
  file,
28
28
  styleInGrid,
29
29
  onUploadComplete,
30
- }: MediaViewProps): JSX.Element {
30
+ }: MediaViewProps) {
31
31
  const { t } = useAtlantisI18n();
32
32
  const { useCreateThumbnail } = useAtlantisFormatFileContext();
33
33
  const { thumbnail, error } = useCreateThumbnail(file);
34
34
  const [isLoading, setIsLoading] = useState(false);
35
+ /**
36
+ * Tracks whether onLoadEnd has fired to prevent race conditions.
37
+ * ImageBackground can fire onLoadEnd before onLoadStart when loading cached images,
38
+ * which would cause isLoading to get stuck at true, showing an infinite spinner.
39
+ */
40
+ const hasLoadedRef = useRef(false);
35
41
 
36
42
  const a11yLabel = computeA11yLabel({
37
43
  accessibilityLabel,
@@ -40,10 +46,25 @@ export function MediaView({
40
46
  t,
41
47
  });
42
48
 
43
- const hasError = showError || error;
44
- const uri = thumbnail || file.thumbnailUrl || file.source;
49
+ const hasError = showError || error,
50
+ uri = thumbnail || file.thumbnailUrl || file.source,
51
+ styles = useStyles();
45
52
 
46
- const styles = useStyles();
53
+ const handleLoadStart = () => {
54
+ if (!hasLoadedRef.current) {
55
+ setIsLoading(true);
56
+ }
57
+ };
58
+
59
+ const handleLoadEnd = () => {
60
+ hasLoadedRef.current = true;
61
+ setIsLoading(false);
62
+ };
63
+
64
+ useEffect(() => {
65
+ hasLoadedRef.current = false;
66
+ setIsLoading(false);
67
+ }, [uri]);
47
68
 
48
69
  return (
49
70
  <View accessible={true} accessibilityLabel={a11yLabel}>
@@ -55,8 +76,8 @@ export function MediaView({
55
76
  resizeMode={styleInGrid ? "cover" : "contain"}
56
77
  source={{ uri }}
57
78
  testID={"test-image"}
58
- onLoadStart={() => setIsLoading(true)}
59
- onLoadEnd={() => setIsLoading(false)}
79
+ onLoadStart={handleLoadStart}
80
+ onLoadEnd={handleLoadEnd}
60
81
  >
61
82
  <Overlay
62
83
  isLoading={isLoading}
@@ -22,7 +22,7 @@ export const ProgressBar = ({
22
22
  progress,
23
23
  status,
24
24
  onComplete,
25
- }: ProgressBarProps): JSX.Element => {
25
+ }: ProgressBarProps) => {
26
26
  const barWidth = useRef(new Animated.Value(0)).current;
27
27
  const progressPercentage = barWidth.interpolate({
28
28
  inputRange: [0, 1],
@@ -71,7 +71,7 @@ export function Heading<T extends HeadingLevel = "heading">({
71
71
  maxLines = "unlimited",
72
72
  allowFontScaling = true,
73
73
  selectable,
74
- }: HeadingProps<T>): JSX.Element {
74
+ }: HeadingProps<T>) {
75
75
  const headingStyle = getHeadingStyle(level, variation);
76
76
  const accessibilityRole = "header";
77
77
 
package/src/Icon/Icon.tsx CHANGED
@@ -37,7 +37,7 @@ export function Icon({
37
37
  size = "base",
38
38
  customColor,
39
39
  testID,
40
- }: IconProps): JSX.Element {
40
+ }: IconProps) {
41
41
  const { svgStyle, paths, viewBox } = getIcon({
42
42
  name,
43
43
  color,
@@ -50,7 +50,7 @@ export function IconButton({
50
50
  onPress,
51
51
  accessibilityLabel,
52
52
  testID,
53
- }: IconButtonProps): JSX.Element {
53
+ }: IconButtonProps) {
54
54
  const styles = useStyles();
55
55
 
56
56
  return (
@@ -130,7 +130,7 @@ const computeDisplayFromNumericInput = (
130
130
  }
131
131
  };
132
132
 
133
- export function InputCurrency(props: InputCurrencyProps): JSX.Element {
133
+ export function InputCurrency(props: InputCurrencyProps) {
134
134
  const {
135
135
  showCurrencySymbol = true,
136
136
  maxDecimalPlaces = 5,
@@ -8,9 +8,11 @@ import type { InputFieldWrapperProps } from "../InputFieldWrapper";
8
8
  import { FormField } from "../FormField";
9
9
  import { InputPressable } from "../InputPressable";
10
10
  import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
11
+ import type { InputPressableProps } from "../InputPressable/InputPressable";
11
12
 
12
13
  interface BaseInputDateProps
13
- extends Pick<InputFieldWrapperProps, "invalid" | "disabled" | "placeholder"> {
14
+ extends Pick<InputFieldWrapperProps, "invalid" | "disabled" | "placeholder">,
15
+ Pick<InputPressableProps, "showMiniLabel"> {
14
16
  /**
15
17
  * Defaulted to "always" so user can clear the dates whenever there's a value.
16
18
  */
@@ -109,7 +111,7 @@ const display = Platform.OS === "ios" ? "inline" : "default";
109
111
  /**
110
112
  * Allow users to select a date using the device date picker.
111
113
  */
112
- export function InputDate(props: InputDateProps): JSX.Element {
114
+ export function InputDate(props: InputDateProps) {
113
115
  if (props.name) {
114
116
  return (
115
117
  <FormField<Date>
@@ -145,11 +147,12 @@ function InternalInputDate({
145
147
  minDate,
146
148
  placeholder,
147
149
  value,
150
+ showMiniLabel = true,
148
151
  name,
149
152
  onChange,
150
153
  accessibilityLabel,
151
154
  accessibilityHint,
152
- }: InputDateProps): JSX.Element {
155
+ }: InputDateProps) {
153
156
  const [showPicker, setShowPicker] = useState(false);
154
157
  const { t, locale, formatDate } = useAtlantisI18n();
155
158
 
@@ -174,6 +177,7 @@ function InternalInputDate({
174
177
  return (
175
178
  <>
176
179
  <InputPressable
180
+ showMiniLabel={showMiniLabel}
177
181
  focused={showPicker}
178
182
  clearable={canClearDate}
179
183
  disabled={disabled}
@@ -1,6 +1,11 @@
1
1
  import React from "react";
2
2
  import type { RenderAPI } from "@testing-library/react-native";
3
- import { fireEvent, render, renderHook } from "@testing-library/react-native";
3
+ import {
4
+ fireEvent,
5
+ render,
6
+ renderHook,
7
+ screen,
8
+ } from "@testing-library/react-native";
4
9
  import type { ViewStyle } from "react-native";
5
10
  import { Text } from "react-native";
6
11
  import type { InputFieldWrapperProps } from ".";
@@ -311,4 +316,46 @@ describe("InputFieldWrapper", () => {
311
316
  expect(queryByTestId(INPUT_FIELD_WRAPPER_SPINNER_TEST_ID)).toBeNull();
312
317
  });
313
318
  });
319
+
320
+ describe("placeholderMode", () => {
321
+ it("renders the placeholder in its normal position", () => {
322
+ renderInputFieldWrapper({
323
+ placeholder: "placeholder",
324
+ placeholderMode: "normal",
325
+ });
326
+ const placeholder = screen.getByText("placeholder", {
327
+ includeHiddenElements: true,
328
+ });
329
+ expect(placeholder).toBeDefined();
330
+ expect(placeholder.props.style).toContainEqual(
331
+ typographyStyles.defaultSize,
332
+ );
333
+ });
334
+
335
+ it("renders the placeholder in its mini label position", () => {
336
+ renderInputFieldWrapper({
337
+ placeholder: "placeholder",
338
+ placeholderMode: "mini",
339
+ });
340
+ const placeholder = screen.getByText("placeholder", {
341
+ includeHiddenElements: true,
342
+ });
343
+ expect(placeholder).toBeDefined();
344
+ expect(placeholder.props.style).toContainEqual(
345
+ typographyStyles.smallSize,
346
+ );
347
+ });
348
+
349
+ it("does not render the placeholder", () => {
350
+ renderInputFieldWrapper({
351
+ placeholder: "placeholder",
352
+ placeholderMode: "hidden",
353
+ });
354
+ expect(
355
+ screen.queryByText("placeholder", {
356
+ includeHiddenElements: true,
357
+ }),
358
+ ).toBeNull();
359
+ });
360
+ });
314
361
  });
@@ -43,7 +43,14 @@ export interface InputFieldWrapperProps {
43
43
  */
44
44
  readonly assistiveText?: string;
45
45
 
46
- readonly hasMiniLabel?: boolean;
46
+ /**
47
+ * Controls how the placeholder text is displayed.
48
+ * - normal: the placeholder text will be displayed in the normal placeholder position
49
+ * - mini: the placeholder text will float above the input value
50
+ * - hidden: the placeholder text will not be displayed
51
+ * @default "normal"
52
+ */
53
+ readonly placeholderMode?: "normal" | "mini" | "hidden";
47
54
 
48
55
  readonly hasValue?: boolean;
49
56
 
@@ -119,7 +126,7 @@ export function InputFieldWrapper({
119
126
  assistiveText,
120
127
  prefix,
121
128
  suffix,
122
- hasMiniLabel = false,
129
+ placeholderMode = "normal",
123
130
  hasValue = false,
124
131
  error,
125
132
  focused = false,
@@ -131,7 +138,7 @@ export function InputFieldWrapper({
131
138
  toolbarVisibility = "while-editing",
132
139
  loading = false,
133
140
  loadingType = "spinner",
134
- }: InputFieldWrapperProps): JSX.Element {
141
+ }: InputFieldWrapperProps) {
135
142
  fieldAffixRequiredPropsCheck([prefix, suffix]);
136
143
  const handleClear = onClear ?? noopClear;
137
144
  warnIfClearActionWithNoOnClear(onClear, showClearAction);
@@ -143,6 +150,9 @@ export function InputFieldWrapper({
143
150
  const showLoadingGlimmer = loading && loadingType === "glimmer";
144
151
  const styles = useStyles();
145
152
 
153
+ const placeholderVisible = placeholderMode !== "hidden";
154
+ const miniLabelActive = placeholderMode === "mini";
155
+
146
156
  return (
147
157
  <ErrorMessageWrapper message={getMessage({ invalid, error })}>
148
158
  <View
@@ -160,35 +170,36 @@ export function InputFieldWrapper({
160
170
  <PrefixIcon
161
171
  disabled={disabled}
162
172
  focused={focused}
163
- hasMiniLabel={hasMiniLabel}
164
173
  inputInvalid={inputInvalid}
165
174
  icon={prefix.icon}
166
175
  />
167
176
  )}
168
177
  <View style={[styles.inputContainer]}>
169
- <View
170
- style={[
171
- !!placeholder && styles.label,
172
- hasMiniLabel && styles.miniLabel,
173
- disabled && styles.disabled,
174
- hasMiniLabel &&
175
- showClearAction &&
176
- styles.miniLabelShowClearAction,
177
- ]}
178
- pointerEvents="none"
179
- >
180
- <Placeholder
181
- placeholder={placeholder}
182
- labelVariation={getLabelVariation(error, invalid, disabled)}
183
- hasMiniLabel={hasMiniLabel}
184
- styleOverride={styleOverride?.placeholderText}
185
- />
186
- </View>
178
+ {placeholderVisible && (
179
+ <View
180
+ style={[
181
+ !!placeholder && styles.label,
182
+ miniLabelActive && styles.miniLabel,
183
+ disabled && styles.disabled,
184
+ miniLabelActive &&
185
+ showClearAction &&
186
+ styles.miniLabelShowClearAction,
187
+ ]}
188
+ pointerEvents="none"
189
+ >
190
+ <Placeholder
191
+ placeholder={placeholder}
192
+ labelVariation={getLabelVariation(error, invalid, disabled)}
193
+ miniLabelActive={miniLabelActive}
194
+ styleOverride={styleOverride?.placeholderText}
195
+ />
196
+ </View>
197
+ )}
187
198
  {prefix?.label && hasValue && (
188
199
  <PrefixLabel
189
200
  disabled={disabled}
190
201
  focused={focused}
191
- hasMiniLabel={hasMiniLabel}
202
+ miniLabelActive={miniLabelActive}
192
203
  inputInvalid={inputInvalid}
193
204
  label={prefix.label}
194
205
  styleOverride={styleOverride?.prefixLabel}
@@ -225,7 +236,7 @@ export function InputFieldWrapper({
225
236
  <SuffixLabel
226
237
  disabled={disabled}
227
238
  focused={focused}
228
- hasMiniLabel={hasMiniLabel}
239
+ miniLabelActive={miniLabelActive}
229
240
  inputInvalid={inputInvalid}
230
241
  label={suffix.label}
231
242
  hasLeftMargin={!showClearAction}
@@ -245,7 +256,6 @@ export function InputFieldWrapper({
245
256
  <SuffixIcon
246
257
  disabled={disabled}
247
258
  focused={focused}
248
- hasMiniLabel={hasMiniLabel}
249
259
  hasLeftMargin={!!(!showClearAction || suffix?.label)}
250
260
  inputInvalid={inputInvalid}
251
261
  icon={suffix.icon}
@@ -332,12 +342,12 @@ function Placeholder({
332
342
  placeholder,
333
343
  styleOverride,
334
344
  labelVariation,
335
- hasMiniLabel,
345
+ miniLabelActive,
336
346
  }: {
337
347
  readonly placeholder?: string;
338
348
  readonly styleOverride: StyleProp<TextStyle>;
339
349
  readonly labelVariation: TextVariation;
340
- readonly hasMiniLabel: boolean;
350
+ readonly miniLabelActive: boolean;
341
351
  }) {
342
352
  const typographyStyles = useTypographyStyles();
343
353
 
@@ -348,7 +358,7 @@ function Placeholder({
348
358
  hideFromScreenReader={true}
349
359
  maxLines="single"
350
360
  variation={labelVariation}
351
- level={hasMiniLabel ? "textSupporting" : "text"}
361
+ level={miniLabelActive ? "textSupporting" : "text"}
352
362
  >
353
363
  {placeholder}
354
364
  </Text>
@@ -361,7 +371,7 @@ function Placeholder({
361
371
  style={[
362
372
  typographyStyles[labelVariation],
363
373
  typographyStyles.baseRegularRegular,
364
- hasMiniLabel
374
+ miniLabelActive
365
375
  ? typographyStyles.smallSize
366
376
  : typographyStyles.defaultSize,
367
377
  styleOverride,
@@ -15,7 +15,7 @@ interface ClearActionProps {
15
15
  export function ClearAction({
16
16
  onPress,
17
17
  hasMarginRight = false,
18
- }: ClearActionProps): JSX.Element {
18
+ }: ClearActionProps) {
19
19
  const { t } = useAtlantisI18n();
20
20
  const styles = useStyles();
21
21