@jobber/components-native 0.84.4-JOB-134681-8086ad4.25 → 0.84.4-JOB-138679-b1552ab.68

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 (278) hide show
  1. package/dist/package.json +23 -14
  2. package/dist/src/ActionItem/ActionItemGroup.js +1 -1
  3. package/dist/src/AutoLink/components/Link/Link.js +1 -1
  4. package/dist/src/Banner/Banner.js +2 -0
  5. package/dist/src/Banner/components/BannerIcon/BannerIcon.style.js +3 -0
  6. package/dist/src/BottomSheet/BottomSheet.js +2 -2
  7. package/dist/src/Button/components/InternalButtonLoading/InternalButtonLoading.js +0 -1
  8. package/dist/src/ButtonGroup/ButtonGroup.js +1 -1
  9. package/dist/src/ContentOverlay/ContentOverlay.js +5 -7
  10. package/dist/src/ContentOverlay/UNSAFE_WrappedModalize.js +23 -0
  11. package/dist/src/ErrorMessageWrapper/context/ErrorMessageProvider.js +1 -1
  12. package/dist/src/Form/Form.js +5 -2
  13. package/dist/src/Form/components/FormCache/FormCache.js +1 -0
  14. package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.js +1 -1
  15. package/dist/src/Form/context/AtlantisFormContext.js +1 -0
  16. package/dist/src/Form/hooks/useInternalForm.js +6 -3
  17. package/dist/src/FormatFile/components/MediaView/MediaView.js +22 -5
  18. package/dist/src/FormatFile/utils/createUseCreateThumbnail.js +1 -1
  19. package/dist/src/InputCurrency/InputCurrency.js +42 -30
  20. package/dist/src/InputDate/InputDate.js +2 -2
  21. package/dist/src/InputEmail/InputEmail.js +12 -4
  22. package/dist/src/InputFieldWrapper/InputFieldWrapper.js +14 -12
  23. package/dist/src/InputFieldWrapper/InputFieldWrapper.style.js +1 -1
  24. package/dist/src/InputFieldWrapper/components/Prefix/Prefix.js +5 -2
  25. package/dist/src/InputFieldWrapper/components/Suffix/Suffix.js +5 -2
  26. package/dist/src/InputNumber/InputNumber.js +10 -4
  27. package/dist/src/InputPressable/InputPressable.js +20 -8
  28. package/dist/src/InputPressable/InputPressable.style.js +3 -0
  29. package/dist/src/InputSearch/InputSearch.js +1 -1
  30. package/dist/src/InputText/InputText.js +22 -11
  31. package/dist/src/InputText/InputText.style.js +4 -0
  32. package/dist/src/InputTime/InputTime.js +2 -2
  33. package/dist/src/Menu/Menu.js +2 -2
  34. package/dist/src/Select/Select.style.js +1 -0
  35. package/dist/src/Select/components/SelectPressable/SelectPressable.js +1 -1
  36. package/dist/src/Switch/components/BaseSwitch/BaseSwitch.js +7 -1
  37. package/dist/src/Typography/Typography.js +16 -5
  38. package/dist/src/hooks/useAtlantisI18n/locales/en.json +1 -0
  39. package/dist/src/hooks/useAtlantisI18n/locales/es.json +1 -0
  40. package/dist/src/hooks/useFormController.js +5 -14
  41. package/dist/tsconfig.build.json +7 -0
  42. package/dist/tsconfig.build.tsbuildinfo +1 -0
  43. package/dist/tsconfig.json +4 -6
  44. package/dist/types/src/ActionItem/ActionItem.d.ts +2 -1
  45. package/dist/types/src/ActionItem/ActionItemGroup.d.ts +2 -1
  46. package/dist/types/src/ActionItem/components/ActionItemContainer.d.ts +2 -1
  47. package/dist/types/src/ActionLabel/ActionLabel.d.ts +4 -3
  48. package/dist/types/src/ActivityIndicator/ActivityIndicator.d.ts +2 -1
  49. package/dist/types/src/AutoLink/AutoLink.d.ts +2 -1
  50. package/dist/types/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.d.ts +2 -1
  51. package/dist/types/src/AutoLink/components/Link/Link.d.ts +2 -1
  52. package/dist/types/src/Banner/Banner.d.ts +2 -1
  53. package/dist/types/src/Banner/components/BannerIcon/BannerIcon.d.ts +2 -1
  54. package/dist/types/src/Banner/components/BannerIcon/BannerIcon.style.d.ts +3 -0
  55. package/dist/types/src/Banner/types.d.ts +1 -1
  56. package/dist/types/src/BottomSheet/BottomSheet.d.ts +1 -1
  57. package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.d.ts +2 -1
  58. package/dist/types/src/Button/Button.d.ts +2 -1
  59. package/dist/types/src/Button/components/InternalButtonLoading/InternalButtonLoading.d.ts +1 -1
  60. package/dist/types/src/ButtonGroup/ButtonGroup.d.ts +2 -1
  61. package/dist/types/src/ButtonGroup/ButtonGroupAction.d.ts +4 -3
  62. package/dist/types/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.d.ts +3 -2
  63. package/dist/types/src/Card/Card.d.ts +2 -1
  64. package/dist/types/src/Card/components/InternalCardHeader.d.ts +2 -1
  65. package/dist/types/src/Checkbox/Checkbox.d.ts +2 -1
  66. package/dist/types/src/Checkbox/CheckboxGroup.d.ts +2 -1
  67. package/dist/types/src/Chip/Chip.d.ts +2 -1
  68. package/dist/types/src/Content/Content.d.ts +2 -1
  69. package/dist/types/src/ContentOverlay/ContentOverlay.d.ts +1 -1
  70. package/dist/types/src/ContentOverlay/UNSAFE_WrappedModalize.d.ts +3 -0
  71. package/dist/types/src/Disclosure/Disclosure.d.ts +1 -1
  72. package/dist/types/src/Divider/Divider.d.ts +2 -1
  73. package/dist/types/src/EmptyState/EmptyState.d.ts +2 -1
  74. package/dist/types/src/ErrorMessageWrapper/ErrorMessageWrapper.d.ts +2 -1
  75. package/dist/types/src/ErrorMessageWrapper/context/ErrorMessageProvider.d.ts +2 -1
  76. package/dist/types/src/ErrorMessageWrapper/context/types.d.ts +1 -1
  77. package/dist/types/src/Flex/Flex.d.ts +2 -1
  78. package/dist/types/src/Form/Form.d.ts +2 -1
  79. package/dist/types/src/Form/components/FormActionBar/FormActionBar.d.ts +3 -2
  80. package/dist/types/src/Form/components/FormBody/FormBody.d.ts +3 -2
  81. package/dist/types/src/Form/components/FormCache/FormCache.d.ts +4 -3
  82. package/dist/types/src/Form/components/FormErrorBanner/FormErrorBanner.d.ts +2 -1
  83. package/dist/types/src/Form/components/FormMask/FormMask.d.ts +2 -1
  84. package/dist/types/src/Form/components/FormMessage/FormMessage.d.ts +2 -1
  85. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.d.ts +2 -1
  86. package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.d.ts +2 -1
  87. package/dist/types/src/Form/components/FormSaveButton/FormSaveButton.d.ts +2 -1
  88. package/dist/types/src/Form/context/AtlantisFormContext.d.ts +2 -1
  89. package/dist/types/src/Form/context/types.d.ts +3 -2
  90. package/dist/types/src/Form/hooks/useFormViewRefs.d.ts +2 -2
  91. package/dist/types/src/Form/hooks/useInternalForm.d.ts +5 -5
  92. package/dist/types/src/Form/types.d.ts +13 -7
  93. package/dist/types/src/FormField/FormField.d.ts +1 -1
  94. package/dist/types/src/FormatFile/FormatFile.d.ts +2 -1
  95. package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.d.ts +2 -1
  96. package/dist/types/src/FormatFile/components/FileView/FileView.d.ts +2 -1
  97. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.d.ts +3 -2
  98. package/dist/types/src/FormatFile/components/MediaView/MediaView.d.ts +2 -1
  99. package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.d.ts +2 -1
  100. package/dist/types/src/Heading/Heading.d.ts +4 -3
  101. package/dist/types/src/Icon/Icon.d.ts +2 -1
  102. package/dist/types/src/IconButton/IconButton.d.ts +1 -1
  103. package/dist/types/src/InputCurrency/InputCurrency.d.ts +2 -1
  104. package/dist/types/src/InputDate/InputDate.d.ts +4 -2
  105. package/dist/types/src/InputFieldWrapper/InputFieldWrapper.d.ts +9 -2
  106. package/dist/types/src/InputFieldWrapper/InputFieldWrapper.style.d.ts +1 -1
  107. package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.d.ts +2 -1
  108. package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.d.ts +4 -4
  109. package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.d.ts +4 -4
  110. package/dist/types/src/InputPressable/InputPressable.d.ts +9 -1
  111. package/dist/types/src/InputPressable/InputPressable.style.d.ts +3 -0
  112. package/dist/types/src/InputSearch/InputSearch.d.ts +1 -1
  113. package/dist/types/src/InputSearch/components/FilterButton.d.ts +2 -1
  114. package/dist/types/src/InputText/InputText.d.ts +10 -2
  115. package/dist/types/src/InputText/InputText.style.d.ts +4 -0
  116. package/dist/types/src/InputText/context/InputAccessoriesProvider.d.ts +2 -1
  117. package/dist/types/src/InputTime/InputTime.d.ts +4 -2
  118. package/dist/types/src/Menu/Menu.d.ts +2 -1
  119. package/dist/types/src/Menu/components/MenuOption/MenuOption.d.ts +2 -1
  120. package/dist/types/src/Menu/components/Overlay/Overlay.d.ts +2 -1
  121. package/dist/types/src/Menu/types.d.ts +6 -1
  122. package/dist/types/src/ProgressBar/ProgressBar.d.ts +2 -1
  123. package/dist/types/src/ProgressBar/ProgressBarInner.d.ts +2 -1
  124. package/dist/types/src/Select/Select.d.ts +3 -2
  125. package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.d.ts +2 -1
  126. package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.d.ts +2 -1
  127. package/dist/types/src/Select/components/SelectInternalPicker/SelectInternalPicker.d.ts +2 -1
  128. package/dist/types/src/Select/components/SelectPressable/SelectPressable.d.ts +2 -1
  129. package/dist/types/src/StatusLabel/StatusLabel.d.ts +2 -1
  130. package/dist/types/src/Switch/Switch.d.ts +2 -1
  131. package/dist/types/src/Switch/components/BaseSwitch/BaseSwitch.d.ts +2 -1
  132. package/dist/types/src/Text/Text.d.ts +4 -3
  133. package/dist/types/src/TextList/TextList.d.ts +2 -1
  134. package/dist/types/src/ThumbnailList/ThumbnailList.d.ts +2 -1
  135. package/dist/types/src/Toast/Toast.d.ts +2 -1
  136. package/dist/types/src/Typography/Typography.d.ts +3 -3
  137. package/dist/types/src/Typography/TypographyGestureDetector.d.ts +2 -1
  138. package/dist/types/src/utils/test/MockSafeAreaProvider.d.ts +1 -1
  139. package/package.json +23 -14
  140. package/src/ActionItem/ActionItem.tsx +1 -1
  141. package/src/ActionItem/ActionItemGroup.tsx +1 -3
  142. package/src/ActionItem/components/ActionItemContainer.tsx +1 -1
  143. package/src/ActionLabel/ActionLabel.test.tsx +12 -0
  144. package/src/ActionLabel/ActionLabel.tsx +3 -3
  145. package/src/ActionLabel/__snapshots__/ActionLabel.test.tsx.snap +66 -0
  146. package/src/ActivityIndicator/ActivityIndicator.tsx +1 -3
  147. package/src/AtlantisContext/AtlantisContext.test.tsx +1 -1
  148. package/src/AtlantisThemeContext/AtlantisThemeContext.test.tsx +5 -5
  149. package/src/AutoLink/AutoLink.test.tsx +2 -4
  150. package/src/AutoLink/AutoLink.tsx +1 -1
  151. package/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.tsx +1 -1
  152. package/src/AutoLink/components/Link/Link.tsx +1 -5
  153. package/src/Banner/Banner.test.tsx +12 -0
  154. package/src/Banner/Banner.tsx +4 -2
  155. package/src/Banner/components/BannerIcon/BannerIcon.style.ts +3 -0
  156. package/src/Banner/components/BannerIcon/BannerIcon.tsx +1 -1
  157. package/src/Banner/types.ts +1 -1
  158. package/src/BottomSheet/BottomSheet.test.tsx +17 -17
  159. package/src/BottomSheet/BottomSheet.tsx +4 -3
  160. package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.tsx +1 -1
  161. package/src/Button/Button.tsx +1 -1
  162. package/src/Button/components/InternalButtonLoading/InternalButtonLoading.tsx +1 -2
  163. package/src/ButtonGroup/ButtonGroup.test.tsx +13 -11
  164. package/src/ButtonGroup/ButtonGroup.tsx +2 -2
  165. package/src/ButtonGroup/ButtonGroupAction.tsx +4 -4
  166. package/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.tsx +2 -2
  167. package/src/Card/Card.tsx +1 -1
  168. package/src/Card/components/InternalCardHeader.tsx +1 -1
  169. package/src/Checkbox/Checkbox.tsx +2 -2
  170. package/src/Checkbox/CheckboxGroup.test.tsx +3 -7
  171. package/src/Checkbox/CheckboxGroup.tsx +2 -2
  172. package/src/Chip/Chip.tsx +1 -1
  173. package/src/Content/Content.tsx +1 -1
  174. package/src/ContentOverlay/ContentOverlay.test.tsx +34 -27
  175. package/src/ContentOverlay/ContentOverlay.tsx +7 -7
  176. package/src/ContentOverlay/UNSAFE_WrappedModalize.tsx +41 -0
  177. package/src/ContentOverlay/hooks/useKeyboardVisibility.test.ts +7 -7
  178. package/src/ContentOverlay/hooks/useViewLayoutHeight.test.ts +1 -1
  179. package/src/Disclosure/Disclosure.tsx +1 -1
  180. package/src/Divider/Divider.tsx +1 -1
  181. package/src/EmptyState/EmptyState.test.tsx +29 -42
  182. package/src/EmptyState/EmptyState.tsx +1 -1
  183. package/src/ErrorMessageWrapper/ErrorMessageWrapper.tsx +1 -1
  184. package/src/ErrorMessageWrapper/context/ErrorMessageProvider.tsx +3 -5
  185. package/src/ErrorMessageWrapper/context/types.ts +1 -1
  186. package/src/Flex/Flex.tsx +2 -2
  187. package/src/Form/Form.test.tsx +145 -2
  188. package/src/Form/Form.tsx +8 -1
  189. package/src/Form/components/FormActionBar/FormActionBar.tsx +3 -3
  190. package/src/Form/components/FormBody/FormBody.tsx +3 -3
  191. package/src/Form/components/FormCache/FormCache.tsx +5 -4
  192. package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +1 -1
  193. package/src/Form/components/FormMask/FormMask.tsx +1 -1
  194. package/src/Form/components/FormMessage/FormMessage.test.tsx +40 -27
  195. package/src/Form/components/FormMessage/FormMessage.tsx +1 -1
  196. package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +1 -1
  197. package/src/Form/components/FormMessageBanner/FormMessageBanner.tsx +1 -3
  198. package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +2 -2
  199. package/src/Form/components/FormSaveButton/FormSaveButton.tsx +1 -1
  200. package/src/Form/context/AtlantisFormContext.test.tsx +1 -1
  201. package/src/Form/context/AtlantisFormContext.tsx +1 -0
  202. package/src/Form/context/types.ts +3 -2
  203. package/src/Form/hooks/useFormViewRefs.ts +4 -5
  204. package/src/Form/hooks/useInternalForm.ts +12 -4
  205. package/src/Form/hooks/useScrollToError/useScrollToError.test.tsx +2 -1
  206. package/src/Form/types.ts +14 -8
  207. package/src/FormField/FormField.tsx +1 -1
  208. package/src/FormatFile/FormatFile.test.tsx +21 -21
  209. package/src/FormatFile/FormatFile.tsx +3 -3
  210. package/src/FormatFile/components/ErrorIcon/ErrorIcon.tsx +1 -1
  211. package/src/FormatFile/components/FileView/FileView.tsx +1 -1
  212. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +14 -14
  213. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +2 -2
  214. package/src/FormatFile/components/MediaView/MediaView.test.tsx +283 -0
  215. package/src/FormatFile/components/MediaView/MediaView.tsx +28 -7
  216. package/src/FormatFile/components/ProgressBar/ProgressBar.tsx +1 -1
  217. package/src/FormatFile/utils/createUseCreateThumbnail.ts +1 -1
  218. package/src/Glimmer/Glimmer.test.tsx +2 -2
  219. package/src/Heading/Heading.test.tsx +13 -0
  220. package/src/Heading/Heading.tsx +3 -3
  221. package/src/Heading/__snapshots__/Heading.test.tsx.snap +65 -0
  222. package/src/Icon/Icon.tsx +1 -1
  223. package/src/Icon/__snapshots__/Icon.test.tsx.snap +7 -0
  224. package/src/IconButton/IconButton.tsx +1 -1
  225. package/src/InputCurrency/InputCurrency.tsx +72 -58
  226. package/src/InputDate/InputDate.tsx +7 -3
  227. package/src/InputEmail/InputEmail.tsx +15 -8
  228. package/src/InputFieldWrapper/InputFieldWrapper.style.ts +1 -1
  229. package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +48 -1
  230. package/src/InputFieldWrapper/InputFieldWrapper.tsx +39 -29
  231. package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +1 -1
  232. package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +8 -16
  233. package/src/InputFieldWrapper/components/Prefix/Prefix.tsx +8 -6
  234. package/src/InputFieldWrapper/components/Suffix/Suffix.test.tsx +2 -4
  235. package/src/InputFieldWrapper/components/Suffix/Suffix.tsx +8 -6
  236. package/src/InputNumber/InputNumber.tsx +11 -7
  237. package/src/InputPassword/InputPassword.tsx +1 -1
  238. package/src/InputPressable/InputPressable.style.ts +4 -0
  239. package/src/InputPressable/InputPressable.test.tsx +75 -1
  240. package/src/InputPressable/InputPressable.tsx +34 -8
  241. package/src/InputSearch/InputSearch.tsx +2 -1
  242. package/src/InputSearch/components/FilterButton.tsx +1 -1
  243. package/src/InputText/InputText.style.ts +5 -0
  244. package/src/InputText/InputText.test.tsx +75 -0
  245. package/src/InputText/InputText.tsx +34 -17
  246. package/src/InputText/context/InputAccessoriesProvider.tsx +1 -1
  247. package/src/InputTime/InputTime.tsx +7 -3
  248. package/src/Menu/Menu.tsx +3 -3
  249. package/src/Menu/components/MenuOption/MenuOption.tsx +1 -1
  250. package/src/Menu/components/Overlay/Overlay.tsx +1 -1
  251. package/src/Menu/types.ts +7 -1
  252. package/src/ProgressBar/ProgressBar.tsx +1 -1
  253. package/src/ProgressBar/ProgressBarInner.tsx +1 -1
  254. package/src/Select/Select.style.ts +1 -0
  255. package/src/Select/Select.tsx +2 -2
  256. package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.tsx +1 -1
  257. package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.tsx +1 -1
  258. package/src/Select/components/SelectInternalPicker/SelectInternalPicker.tsx +1 -1
  259. package/src/Select/components/SelectPressable/SelectPressable.tsx +1 -4
  260. package/src/StatusLabel/StatusLabel.tsx +1 -1
  261. package/src/Switch/Switch.tsx +1 -1
  262. package/src/Switch/components/BaseSwitch/BaseSwitch.tsx +8 -2
  263. package/src/Text/Text.test.tsx +10 -0
  264. package/src/Text/Text.tsx +3 -3
  265. package/src/Text/__snapshots__/Text.test.tsx.snap +66 -0
  266. package/src/TextList/TextList.tsx +1 -1
  267. package/src/ThumbnailList/ThumbnailList.test.tsx +5 -5
  268. package/src/ThumbnailList/ThumbnailList.tsx +1 -1
  269. package/src/Toast/Toast.tsx +2 -2
  270. package/src/Typography/Typography.test.tsx +61 -0
  271. package/src/Typography/Typography.tsx +25 -9
  272. package/src/Typography/TypographyGestureDetector.tsx +1 -3
  273. package/src/Typography/__snapshots__/Typography.test.tsx.snap +222 -0
  274. package/src/hooks/useAtlantisI18n/locales/en.json +1 -0
  275. package/src/hooks/useAtlantisI18n/locales/es.json +1 -0
  276. package/src/hooks/useFormController.ts +6 -13
  277. package/src/utils/test/MockSafeAreaProvider.tsx +1 -1
  278. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -127,7 +127,7 @@ describe("when a secondaryActions is passed in", () => {
127
127
  const beforeSubmitMock = jest.fn().mockImplementation(() => {
128
128
  return Promise.resolve(true);
129
129
  });
130
- const { getByLabelText } = render(
130
+ const { findByLabelText, getByLabelText } = render(
131
131
  <ButtonGroupForTest
132
132
  primaryAction={pressHandler}
133
133
  loading={false}
@@ -145,7 +145,7 @@ describe("when a secondaryActions is passed in", () => {
145
145
  />,
146
146
  );
147
147
  fireEvent.press(getByLabelText("More"));
148
- expect(getByLabelText("hi")).toBeDefined();
148
+ expect(await findByLabelText("hi")).toBeDefined();
149
149
  fireEvent.press(getByLabelText("hi"));
150
150
  expect(beforeSubmitMock).toHaveBeenCalled();
151
151
  await waitFor(() => {
@@ -13,7 +13,7 @@ export function FormSaveButton({
13
13
  setSecondaryActionLoading,
14
14
  onOpenBottomSheet,
15
15
  onCloseBottomSheet,
16
- }: FormSaveButtonProps): JSX.Element {
16
+ }: FormSaveButtonProps) {
17
17
  const { t } = useAtlantisI18n();
18
18
  const formContext = useFormContext();
19
19
  const buttonActions = useButtonGroupAction(secondaryActions);
@@ -1,6 +1,6 @@
1
1
  import type { PropsWithChildren } from "react";
2
2
  import React from "react";
3
- import { renderHook } from "@testing-library/react-hooks";
3
+ import { renderHook } from "@testing-library/react-native";
4
4
  import type { AtlantisFormContextProps } from "./types";
5
5
  import {
6
6
  AtlantisFormContext,
@@ -11,6 +11,7 @@ export const atlantisFormContextDefaultValues = {
11
11
  setLocalCache: () => undefined,
12
12
  removeLocalCache: () => undefined,
13
13
  }),
14
+ edgeToEdgeEnabled: false,
14
15
  };
15
16
 
16
17
  export const AtlantisFormContext = createContext<AtlantisFormContextProps>(
@@ -1,5 +1,5 @@
1
1
  import type { MutableRefObject } from "react";
2
- import type { FieldValues, UseFormReturn } from "react-hook-form";
2
+ import type { DeepPartial, FieldValues, UseFormReturn } from "react-hook-form";
3
3
 
4
4
  export interface UseConfirmBeforeBackProps {
5
5
  alwaysPreventBack: boolean;
@@ -27,7 +27,8 @@ export interface AtlantisFormContextProps {
27
27
  cacheKey?: string,
28
28
  options?: LocalCacheOptions,
29
29
  ) => {
30
- setLocalCache: (data: TData) => void;
30
+ setLocalCache: (data: DeepPartial<TData>) => void;
31
31
  removeLocalCache: () => void;
32
32
  };
33
+ edgeToEdgeEnabled?: boolean;
33
34
  }
@@ -4,15 +4,14 @@ import type { View } from "react-native";
4
4
  import type { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
5
5
 
6
6
  interface UseFormViewRefsReturn {
7
- readonly scrollViewRef: RefObject<KeyboardAwareScrollView>;
8
- readonly bottomViewRef: RefObject<View>;
7
+ readonly scrollViewRef: RefObject<KeyboardAwareScrollView | null>;
8
+ readonly bottomViewRef: RefObject<View | null>;
9
9
  readonly scrollToTop: () => void;
10
10
  }
11
11
 
12
12
  export function useFormViewRefs(): UseFormViewRefsReturn {
13
- const scrollViewRef: RefObject<KeyboardAwareScrollView> =
14
- useRef<KeyboardAwareScrollView>(null);
15
- const bottomViewRef: RefObject<View> = useRef<View>(null);
13
+ const scrollViewRef = useRef<KeyboardAwareScrollView>(null);
14
+ const bottomViewRef = useRef<View>(null);
16
15
  const scrollToTop = useCallback(() => {
17
16
  scrollViewRef.current?.scrollToPosition(0, 0);
18
17
  }, [scrollViewRef]);
@@ -1,4 +1,5 @@
1
1
  import type {
2
+ DeepPartial,
2
3
  FieldValues,
3
4
  UseFormHandleSubmit,
4
5
  UseFormReturn,
@@ -19,8 +20,9 @@ type UseInternalFormProps<T extends FieldValues, SubmitResponseType> = Pick<
19
20
  | "localCacheKey"
20
21
  | "localCacheExclude"
21
22
  | "localCacheId"
23
+ | "UNSAFE_allowDiscardLocalCacheWhenOffline"
22
24
  > & {
23
- scrollViewRef?: RefObject<KeyboardAwareScrollView>;
25
+ scrollViewRef?: RefObject<KeyboardAwareScrollView | null>;
24
26
  readonly saveButtonHeight: number;
25
27
  readonly messageBannerHeight: number;
26
28
  };
@@ -31,7 +33,7 @@ interface UseInternalForm<T extends FieldValues> {
31
33
  readonly isSubmitting: boolean;
32
34
  readonly isDirty: boolean;
33
35
  readonly removeListenerRef: MutableRefObject<() => void>;
34
- readonly setLocalCache: (data: T) => void;
36
+ readonly setLocalCache: (data: DeepPartial<T>) => void;
35
37
  }
36
38
 
37
39
  export function useInternalForm<T extends FieldValues, SubmitResponseType>({
@@ -44,6 +46,7 @@ export function useInternalForm<T extends FieldValues, SubmitResponseType>({
44
46
  scrollViewRef,
45
47
  saveButtonHeight,
46
48
  messageBannerHeight,
49
+ UNSAFE_allowDiscardLocalCacheWhenOffline = false,
47
50
  }: UseInternalFormProps<T, SubmitResponseType>): UseInternalForm<T> {
48
51
  const { useConfirmBeforeBack, useInternalFormLocalCache } =
49
52
  useAtlantisFormContext();
@@ -81,11 +84,16 @@ export function useInternalForm<T extends FieldValues, SubmitResponseType>({
81
84
  };
82
85
  }
83
86
 
87
+ const shouldRemoveCacheOnBack = UNSAFE_allowDiscardLocalCacheWhenOffline
88
+ ? true
89
+ : isOnline;
90
+
84
91
  const removeListenerRef = useConfirmBeforeBack({
85
92
  alwaysPreventBack: isSubmitting,
86
93
  shouldShowAlert: isDirty,
87
- onAcceptEvent: isOnline ? removeLocalCache : undefined,
88
- showLostProgressMessage: isOnline || !clientSideSaveOn ? true : false,
94
+ onAcceptEvent: shouldRemoveCacheOnBack ? removeLocalCache : undefined,
95
+ showLostProgressMessage:
96
+ shouldRemoveCacheOnBack || !clientSideSaveOn ? true : false,
89
97
  });
90
98
 
91
99
  return {
@@ -1,4 +1,4 @@
1
- import { renderHook } from "@testing-library/react-hooks";
1
+ import { renderHook } from "@testing-library/react-native";
2
2
  import { useScrollToError } from "./useScrollToError";
3
3
 
4
4
  const mockFormState = {
@@ -25,6 +25,7 @@ jest.mock("../../../ErrorMessageWrapper", () => ({
25
25
  el: {
26
26
  measure: jest.fn((_, callback) => callback()),
27
27
  hasErrorMessage: true,
28
+ accessibilityFocus: jest.fn(),
28
29
  },
29
30
  },
30
31
  register: jest.fn(),
package/src/Form/types.ts CHANGED
@@ -1,17 +1,16 @@
1
- import type { MutableRefObject, RefObject } from "react";
1
+ import type { ReactElement, RefObject } from "react";
2
2
  import type {
3
3
  ControllerProps,
4
- DeepPartial,
4
+ DefaultValues,
5
5
  FieldPath,
6
6
  FieldValues,
7
7
  Mode,
8
- UnpackNestedValue,
9
8
  UseFormReturn,
10
9
  } from "react-hook-form";
11
10
  import type { IconNames } from "@jobber/design";
12
11
  import type { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
13
12
 
14
- export type FormValues<T> = UnpackNestedValue<T>;
13
+ export type FormValues<T> = T;
15
14
  export type FormErrors = FormNetworkErrors | FormUserErrors;
16
15
  export type FormBannerMessage = FormWarningMessage | FormNoticeMessage;
17
16
 
@@ -55,7 +54,7 @@ interface FormNoticeMessage {
55
54
 
56
55
  export type FormRef<T extends FieldValues = FieldValues> =
57
56
  | (UseFormReturn<T> & {
58
- scrollViewRef?: RefObject<KeyboardAwareScrollView>;
57
+ scrollViewRef?: RefObject<KeyboardAwareScrollView | null>;
59
58
  saveButtonHeight?: number;
60
59
  messageBannerHeight?: number;
61
60
  })
@@ -109,7 +108,7 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
109
108
  * The initial values of the form inputs
110
109
  * This should be available as soon as initialLoading is set to false
111
110
  */
112
- initialValues?: FormValues<DeepPartial<T>>;
111
+ initialValues?: DefaultValues<T>;
113
112
 
114
113
  /**
115
114
  * When the validation should happen.
@@ -128,7 +127,7 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
128
127
  /**
129
128
  * ref object to access react hook form methods and state
130
129
  */
131
- formRef?: MutableRefObject<FormRef<T> | undefined>;
130
+ formRef?: RefObject<FormRef<T> | undefined>;
132
131
 
133
132
  /**
134
133
  * Label to be displayed for the save button
@@ -143,7 +142,7 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
143
142
  onSubmit: () => void,
144
143
  label: string | undefined,
145
144
  isSubmitting: boolean,
146
- ) => JSX.Element;
145
+ ) => ReactElement;
147
146
 
148
147
  /**
149
148
  * Adding a key will save a local copy of the form data that will be used to
@@ -172,6 +171,13 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
172
171
  */
173
172
  localCacheId?: string | string[];
174
173
 
174
+ /**
175
+ * If true, the local cache will be removed when the user navigates away from
176
+ * the dirty form even when offline. By default, cache is only removed on back when online.
177
+ * Defaults to false.
178
+ */
179
+ UNSAFE_allowDiscardLocalCacheWhenOffline?: boolean;
180
+
175
181
  /**
176
182
  * Secondary Action for ButtonGroup
177
183
  */
@@ -39,7 +39,7 @@ export function FormField<T>({
39
39
  children,
40
40
  defaultValue: value,
41
41
  validations,
42
- }: FormFieldProps<T>): JSX.Element {
42
+ }: FormFieldProps<T>) {
43
43
  const { error, field } = useFormController({
44
44
  name,
45
45
  value,
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
2
  import type { RenderAPI } from "@testing-library/react-native";
3
- import { fireEvent, render } from "@testing-library/react-native";
4
- import { Host } from "react-native-portalize";
3
+ import { fireEvent, render, waitFor } from "@testing-library/react-native";
5
4
  import { Alert } from "react-native";
5
+ import { Host } from "react-native-portalize";
6
6
  import type { File } from ".";
7
7
  import { FormatFile } from ".";
8
8
  import {
@@ -117,12 +117,12 @@ function basicRenderTestWithValue() {
117
117
  );
118
118
  });
119
119
 
120
- it("renders ProgressBar state advancing with the upload percentage", () => {
120
+ it("renders ProgressBar state advancing with the upload percentage", async () => {
121
121
  jest.useFakeTimers();
122
122
  const { getByTestId } = renderFormatFile(file);
123
123
  jest.advanceTimersByTime(progressBarAnimationTime);
124
- const formatFileInnerProgressBar = getByTestId(
125
- "format-file-inner-progress-bar",
124
+ const formatFileInnerProgressBar = await waitFor(() =>
125
+ getByTestId("format-file-inner-progress-bar"),
126
126
  );
127
127
  const innerProgressBarWidth = parseInt(
128
128
  formatFileInnerProgressBar.props.style.width,
@@ -210,59 +210,59 @@ function basicRenderTestWithValue() {
210
210
  jest.advanceTimersByTime(progressBarAnimationTime);
211
211
  });
212
212
 
213
- it("shows a BottomSheet with a remove option when tapped", () => {
214
- const { getByTestId, getByLabelText } = tree;
213
+ it("shows a BottomSheet with a remove option when tapped", async () => {
214
+ const { getByTestId, findByLabelText } = tree;
215
215
  fireEvent.press(getByTestId(testId));
216
- expect(getByLabelText(removeLabel)).toBeDefined();
216
+ expect(await findByLabelText(removeLabel)).toBeDefined();
217
217
  });
218
218
 
219
219
  describe("when the BottomSheet remove option is tapped", () => {
220
- it("calls the onRemove action", () => {
221
- const { getByTestId, getByLabelText } = tree;
220
+ it("calls the onRemove action", async () => {
221
+ const { getByTestId, findByLabelText } = tree;
222
222
  fireEvent.press(getByTestId(testId));
223
- fireEvent.press(getByLabelText(removeLabel));
223
+ fireEvent.press(await findByLabelText(removeLabel));
224
224
  expect(onRemove).toHaveBeenCalledTimes(1);
225
225
  });
226
226
  });
227
227
 
228
228
  it("creates a thumbnail when a media file is used", () => {
229
- const expectedCalls = testId.includes("image") ? 2 : 0;
229
+ const expectedCalls = testId.includes("image") ? 1 : 0;
230
230
  expect(mockCreateThumbnail).toHaveBeenCalledTimes(expectedCalls);
231
231
  });
232
232
  },
233
233
  );
234
234
 
235
235
  describe("when the preview option is tapped", () => {
236
- it("calls onPreview with a valid image", () => {
236
+ it("calls onPreview with a valid image", async () => {
237
237
  const previewLabel = "Preview image";
238
- const { getByTestId, getByLabelText } = renderFormatFile(
238
+ const { getByTestId, findByLabelText } = renderFormatFile(
239
239
  FILE_UPLOAD_MOCK_IMAGE({ progress: 1, status: StatusCode.Completed }),
240
240
  "image",
241
241
  );
242
242
  fireEvent.press(getByTestId("test-image"));
243
- fireEvent.press(getByLabelText(previewLabel));
243
+ fireEvent.press(await findByLabelText(previewLabel));
244
244
  expect(mockOnPreview).toHaveBeenCalledTimes(1);
245
245
  });
246
246
 
247
- it("calls onPreview with a valid pdf file", () => {
247
+ it("calls onPreview with a valid pdf file", async () => {
248
248
  const previewLabel = "Preview file";
249
- const { getByTestId, getByLabelText } = renderFormatFile(
249
+ const { getByTestId, findByLabelText } = renderFormatFile(
250
250
  FILE_UPLOAD_MOCK_PDF({ progress: 1, status: StatusCode.Completed }),
251
251
  "file",
252
252
  );
253
253
  fireEvent.press(getByTestId("test-file"));
254
- fireEvent.press(getByLabelText(previewLabel));
254
+ fireEvent.press(await findByLabelText(previewLabel));
255
255
  expect(mockOnPreview).toHaveBeenCalledTimes(1);
256
256
  });
257
257
 
258
- it("calls onPreview with a valid external PDF file", () => {
258
+ it("calls onPreview with a valid external PDF file", async () => {
259
259
  const previewLabel = "Preview file";
260
- const { getByTestId, getByLabelText } = renderFormatFile(
260
+ const { getByTestId, findByLabelText } = renderFormatFile(
261
261
  FILE_MOCK_PDF,
262
262
  "file",
263
263
  );
264
264
  fireEvent.press(getByTestId("test-file"));
265
- fireEvent.press(getByLabelText(previewLabel));
265
+ fireEvent.press(await findByLabelText(previewLabel));
266
266
  expect(mockOnPreview).toHaveBeenCalledTimes(1);
267
267
  });
268
268
 
@@ -88,7 +88,7 @@ function FormatFileContent({
88
88
  styleInGrid,
89
89
  onUploadComplete,
90
90
  isMedia,
91
- }: FormatFileContentProps): JSX.Element {
91
+ }: FormatFileContentProps) {
92
92
  const styles = useStyles();
93
93
 
94
94
  return (
@@ -204,7 +204,7 @@ export function FormatFile<T extends File | FileUpload>({
204
204
  showFileTypeIndicator = true,
205
205
  createThumbnail,
206
206
  onPreviewPress,
207
- }: FormatFileProps<T>): JSX.Element {
207
+ }: FormatFileProps<T>) {
208
208
  const onTapModified = onTap ? () => onTap(file) : () => undefined;
209
209
 
210
210
  const formattedFile = parseFile(file, showFileTypeIndicator);
@@ -236,7 +236,7 @@ function FormatFileInternal({
236
236
  onPreviewPress,
237
237
  testID,
238
238
  createThumbnail: createThumbnailProp,
239
- }: FormatFileInternalProps): JSX.Element {
239
+ }: FormatFileInternalProps) {
240
240
  const [showOverlay, setShowOverlay] = useState<boolean>(
241
241
  file.status !== StatusCode.Completed,
242
242
  );
@@ -3,7 +3,7 @@ import { View } from "react-native";
3
3
  import { useStyles } from "./ErrorIcon.style";
4
4
  import { Icon } from "../../../Icon";
5
5
 
6
- export function ErrorIcon(): JSX.Element {
6
+ export function ErrorIcon() {
7
7
  const styles = useStyles();
8
8
 
9
9
  return (
@@ -27,7 +27,7 @@ export function FileView({
27
27
  showOverlay,
28
28
  showError,
29
29
  onUploadComplete,
30
- }: FileViewProps): JSX.Element {
30
+ }: FileViewProps) {
31
31
  const { t } = useAtlantisI18n();
32
32
  const styles = useStyles();
33
33
 
@@ -39,11 +39,11 @@ const basicRenderTestWithValue = () => {
39
39
  const removeLabel = `Remove ${bottomSheetOptionsSuffix}`;
40
40
  let tree: RenderAPI;
41
41
 
42
- beforeEach(() => {
42
+ beforeEach(async () => {
43
43
  tree = renderBottomSheet(
44
44
  bottomSheetOptionsSuffix as BottomSheetOptionsSuffix,
45
45
  );
46
- act(() => {
46
+ await act(async () => {
47
47
  bottomSheetRef.current?.open();
48
48
  });
49
49
  });
@@ -52,29 +52,29 @@ const basicRenderTestWithValue = () => {
52
52
  });
53
53
 
54
54
  describe("onPreviewPress", () => {
55
- it("renders the preview option", () => {
56
- const { getByLabelText } = tree;
55
+ it("renders the preview option", async () => {
56
+ const { findByLabelText } = tree;
57
57
 
58
- expect(getByLabelText(previewLabel)).toBeDefined();
58
+ expect(await findByLabelText(previewLabel)).toBeDefined();
59
59
  });
60
60
 
61
- it("is called when pressed", () => {
62
- const { getByLabelText } = tree;
63
- fireEvent.press(getByLabelText(previewLabel));
61
+ it("is called when pressed", async () => {
62
+ const { findByLabelText } = tree;
63
+ fireEvent.press(await findByLabelText(previewLabel));
64
64
  expect(onPreview).toHaveBeenCalledTimes(1);
65
65
  });
66
66
  });
67
67
 
68
68
  describe("onRemovePress", () => {
69
- it("renders the remove option", () => {
70
- const { getByLabelText } = tree;
69
+ it("renders the remove option", async () => {
70
+ const { findByLabelText } = tree;
71
71
 
72
- expect(getByLabelText(removeLabel)).toBeDefined();
72
+ expect(await findByLabelText(removeLabel)).toBeDefined();
73
73
  });
74
74
 
75
- it("is called when pressed", () => {
76
- const { getByLabelText } = tree;
77
- fireEvent.press(getByLabelText(removeLabel));
75
+ it("is called when pressed", async () => {
76
+ const { findByLabelText } = tree;
77
+ fireEvent.press(await findByLabelText(removeLabel));
78
78
 
79
79
  expect(onRemove).toHaveBeenCalledTimes(1);
80
80
  });
@@ -9,7 +9,7 @@ import { useAtlantisI18n } from "../../../hooks/useAtlantisI18n";
9
9
  export type BottomSheetOptionsSuffix = "receipt" | "image" | "file" | "video";
10
10
 
11
11
  interface FormatFileBottomSheetProps {
12
- readonly bottomSheetRef: RefObject<BottomSheetRef>;
12
+ readonly bottomSheetRef: RefObject<BottomSheetRef | null>;
13
13
  readonly onPreviewPress?: () => void;
14
14
  readonly onRemovePress?: () => void;
15
15
  readonly bottomSheetOptionsSuffix?: BottomSheetOptionsSuffix;
@@ -20,7 +20,7 @@ export const FormatFileBottomSheet = ({
20
20
  onPreviewPress,
21
21
  onRemovePress,
22
22
  bottomSheetOptionsSuffix,
23
- }: FormatFileBottomSheetProps): JSX.Element => {
23
+ }: FormatFileBottomSheetProps) => {
24
24
  const { t } = useAtlantisI18n();
25
25
 
26
26
  const handlePress = (onPressAction: () => void) => {