@jobber/components-native 0.84.4-match-mobi-55ef4ec.7 → 0.84.4-match-mobi-540af48.10

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 (313) hide show
  1. package/dist/package.json +26 -15
  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 +58 -32
  7. package/dist/src/BottomSheet/BottomSheet.style.js +8 -9
  8. package/dist/src/BottomSheet/hooks/useBottomSheetBackHandler.js +26 -0
  9. package/dist/src/Button/components/InternalButtonLoading/InternalButtonLoading.js +0 -1
  10. package/dist/src/ButtonGroup/ButtonGroup.js +1 -1
  11. package/dist/src/Chip/Chip.js +12 -1
  12. package/dist/src/Chip/Chip.style.js +1 -1
  13. package/dist/src/Content/ContentHorizontal.style.js +15 -0
  14. package/dist/src/Content/ContentSpaceAround.style.js +15 -0
  15. package/dist/src/Content/ContentVertical.style.js +15 -0
  16. package/dist/src/ContentOverlay/ContentOverlay.js +5 -7
  17. package/dist/src/ContentOverlay/UNSAFE_WrappedModalize.js +23 -0
  18. package/dist/src/ErrorMessageWrapper/context/ErrorMessageProvider.js +1 -1
  19. package/dist/src/Form/Form.js +5 -2
  20. package/dist/src/Form/components/FormCache/FormCache.js +1 -0
  21. package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.js +1 -1
  22. package/dist/src/Form/context/AtlantisFormContext.js +1 -0
  23. package/dist/src/Form/hooks/useInternalForm.js +6 -3
  24. package/dist/src/FormatFile/components/MediaView/MediaView.js +22 -5
  25. package/dist/src/FormatFile/utils/createUseCreateThumbnail.js +1 -1
  26. package/dist/src/InputCurrency/InputCurrency.js +42 -30
  27. package/dist/src/InputDate/InputDate.js +2 -2
  28. package/dist/src/InputEmail/InputEmail.js +12 -4
  29. package/dist/src/InputFieldWrapper/InputFieldWrapper.js +14 -12
  30. package/dist/src/InputFieldWrapper/InputFieldWrapper.style.js +1 -1
  31. package/dist/src/InputFieldWrapper/components/Prefix/Prefix.js +5 -2
  32. package/dist/src/InputFieldWrapper/components/Suffix/Suffix.js +5 -2
  33. package/dist/src/InputNumber/InputNumber.js +10 -4
  34. package/dist/src/InputPressable/InputPressable.js +20 -8
  35. package/dist/src/InputPressable/InputPressable.style.js +3 -0
  36. package/dist/src/InputSearch/InputSearch.js +1 -1
  37. package/dist/src/InputText/InputText.js +24 -13
  38. package/dist/src/InputText/InputText.style.js +4 -0
  39. package/dist/src/InputTime/InputTime.js +2 -2
  40. package/dist/src/Menu/Menu.js +2 -2
  41. package/dist/src/ProgressBar/ProgressBar.js +10 -6
  42. package/dist/src/ProgressBar/ProgressBarInner.js +3 -12
  43. package/dist/src/ProgressBar/ProgressBarStepped.js +7 -2
  44. package/dist/src/Select/Select.style.js +1 -0
  45. package/dist/src/Select/components/SelectPressable/SelectPressable.js +1 -1
  46. package/dist/src/StatusLabel/StatusLabel.style.js +2 -2
  47. package/dist/src/Switch/components/BaseSwitch/BaseSwitch.js +7 -1
  48. package/dist/src/Typography/Typography.js +16 -5
  49. package/dist/src/hooks/useAtlantisI18n/locales/en.json +1 -0
  50. package/dist/src/hooks/useAtlantisI18n/locales/es.json +1 -0
  51. package/dist/src/hooks/useFormController.js +6 -15
  52. package/dist/tsconfig.build.json +7 -0
  53. package/dist/tsconfig.build.tsbuildinfo +1 -0
  54. package/dist/tsconfig.json +4 -6
  55. package/dist/types/src/ActionItem/ActionItem.d.ts +2 -1
  56. package/dist/types/src/ActionItem/ActionItemGroup.d.ts +2 -1
  57. package/dist/types/src/ActionItem/components/ActionItemContainer.d.ts +2 -1
  58. package/dist/types/src/ActionLabel/ActionLabel.d.ts +4 -3
  59. package/dist/types/src/ActivityIndicator/ActivityIndicator.d.ts +2 -1
  60. package/dist/types/src/AutoLink/AutoLink.d.ts +2 -1
  61. package/dist/types/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.d.ts +2 -1
  62. package/dist/types/src/AutoLink/components/Link/Link.d.ts +2 -1
  63. package/dist/types/src/Banner/Banner.d.ts +2 -1
  64. package/dist/types/src/Banner/components/BannerIcon/BannerIcon.d.ts +2 -1
  65. package/dist/types/src/Banner/components/BannerIcon/BannerIcon.style.d.ts +3 -0
  66. package/dist/types/src/Banner/types.d.ts +1 -1
  67. package/dist/types/src/BottomSheet/BottomSheet.d.ts +7 -3
  68. package/dist/types/src/BottomSheet/BottomSheet.style.d.ts +7 -14
  69. package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.d.ts +2 -1
  70. package/dist/types/src/BottomSheet/hooks/useBottomSheetBackHandler.d.ts +8 -0
  71. package/dist/types/src/Button/Button.d.ts +2 -1
  72. package/dist/types/src/Button/components/InternalButtonLoading/InternalButtonLoading.d.ts +1 -1
  73. package/dist/types/src/ButtonGroup/ButtonGroup.d.ts +2 -1
  74. package/dist/types/src/ButtonGroup/ButtonGroupAction.d.ts +4 -3
  75. package/dist/types/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.d.ts +3 -2
  76. package/dist/types/src/Card/Card.d.ts +2 -1
  77. package/dist/types/src/Card/components/InternalCardHeader.d.ts +2 -1
  78. package/dist/types/src/Checkbox/Checkbox.d.ts +2 -1
  79. package/dist/types/src/Checkbox/CheckboxGroup.d.ts +2 -1
  80. package/dist/types/src/Chip/Chip.d.ts +2 -1
  81. package/dist/types/src/Content/Content.d.ts +3 -2
  82. package/dist/types/src/Content/ContentHorizontal.style.d.ts +15 -0
  83. package/dist/types/src/Content/ContentSpaceAround.style.d.ts +15 -0
  84. package/dist/types/src/Content/ContentVertical.style.d.ts +15 -0
  85. package/dist/types/src/ContentOverlay/ContentOverlay.d.ts +1 -1
  86. package/dist/types/src/ContentOverlay/UNSAFE_WrappedModalize.d.ts +3 -0
  87. package/dist/types/src/Disclosure/Disclosure.d.ts +1 -1
  88. package/dist/types/src/Divider/Divider.d.ts +2 -1
  89. package/dist/types/src/EmptyState/EmptyState.d.ts +2 -1
  90. package/dist/types/src/ErrorMessageWrapper/ErrorMessageWrapper.d.ts +2 -1
  91. package/dist/types/src/ErrorMessageWrapper/context/ErrorMessageProvider.d.ts +2 -1
  92. package/dist/types/src/ErrorMessageWrapper/context/types.d.ts +1 -1
  93. package/dist/types/src/Flex/Flex.d.ts +2 -1
  94. package/dist/types/src/Form/Form.d.ts +2 -1
  95. package/dist/types/src/Form/components/FormActionBar/FormActionBar.d.ts +3 -2
  96. package/dist/types/src/Form/components/FormBody/FormBody.d.ts +3 -2
  97. package/dist/types/src/Form/components/FormCache/FormCache.d.ts +4 -3
  98. package/dist/types/src/Form/components/FormErrorBanner/FormErrorBanner.d.ts +2 -1
  99. package/dist/types/src/Form/components/FormMask/FormMask.d.ts +2 -1
  100. package/dist/types/src/Form/components/FormMessage/FormMessage.d.ts +2 -1
  101. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.d.ts +2 -1
  102. package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.d.ts +2 -1
  103. package/dist/types/src/Form/components/FormSaveButton/FormSaveButton.d.ts +2 -1
  104. package/dist/types/src/Form/context/AtlantisFormContext.d.ts +2 -1
  105. package/dist/types/src/Form/context/types.d.ts +5 -4
  106. package/dist/types/src/Form/hooks/useFormViewRefs.d.ts +2 -2
  107. package/dist/types/src/Form/hooks/useInternalForm.d.ts +7 -7
  108. package/dist/types/src/Form/types.d.ts +13 -7
  109. package/dist/types/src/FormField/FormField.d.ts +1 -1
  110. package/dist/types/src/FormatFile/FormatFile.d.ts +2 -1
  111. package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.d.ts +2 -1
  112. package/dist/types/src/FormatFile/components/FileView/FileView.d.ts +2 -1
  113. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.d.ts +3 -2
  114. package/dist/types/src/FormatFile/components/MediaView/MediaView.d.ts +2 -1
  115. package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.d.ts +2 -1
  116. package/dist/types/src/Heading/Heading.d.ts +4 -3
  117. package/dist/types/src/Icon/Icon.d.ts +2 -1
  118. package/dist/types/src/IconButton/IconButton.d.ts +1 -1
  119. package/dist/types/src/InputCurrency/InputCurrency.d.ts +2 -1
  120. package/dist/types/src/InputDate/InputDate.d.ts +4 -2
  121. package/dist/types/src/InputFieldWrapper/InputFieldWrapper.d.ts +9 -2
  122. package/dist/types/src/InputFieldWrapper/InputFieldWrapper.style.d.ts +1 -1
  123. package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.d.ts +2 -1
  124. package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.d.ts +4 -4
  125. package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.d.ts +4 -4
  126. package/dist/types/src/InputPressable/InputPressable.d.ts +9 -1
  127. package/dist/types/src/InputPressable/InputPressable.style.d.ts +3 -0
  128. package/dist/types/src/InputSearch/InputSearch.d.ts +1 -1
  129. package/dist/types/src/InputSearch/components/FilterButton.d.ts +2 -1
  130. package/dist/types/src/InputText/InputText.d.ts +11 -3
  131. package/dist/types/src/InputText/InputText.style.d.ts +4 -0
  132. package/dist/types/src/InputText/context/InputAccessoriesProvider.d.ts +2 -1
  133. package/dist/types/src/InputTime/InputTime.d.ts +4 -2
  134. package/dist/types/src/Menu/Menu.d.ts +2 -1
  135. package/dist/types/src/Menu/components/MenuOption/MenuOption.d.ts +2 -1
  136. package/dist/types/src/Menu/components/Overlay/Overlay.d.ts +2 -1
  137. package/dist/types/src/Menu/types.d.ts +6 -1
  138. package/dist/types/src/ProgressBar/ProgressBar.d.ts +2 -1
  139. package/dist/types/src/ProgressBar/ProgressBarInner.d.ts +5 -1
  140. package/dist/types/src/ProgressBar/ProgressBarStepped.d.ts +3 -1
  141. package/dist/types/src/ProgressBar/types.d.ts +20 -0
  142. package/dist/types/src/Select/Select.d.ts +3 -2
  143. package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.d.ts +2 -1
  144. package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.d.ts +2 -1
  145. package/dist/types/src/Select/components/SelectInternalPicker/SelectInternalPicker.d.ts +2 -1
  146. package/dist/types/src/Select/components/SelectPressable/SelectPressable.d.ts +2 -1
  147. package/dist/types/src/StatusLabel/StatusLabel.d.ts +2 -1
  148. package/dist/types/src/StatusLabel/StatusLabel.style.d.ts +1 -1
  149. package/dist/types/src/Switch/Switch.d.ts +2 -1
  150. package/dist/types/src/Switch/components/BaseSwitch/BaseSwitch.d.ts +2 -1
  151. package/dist/types/src/Text/Text.d.ts +4 -3
  152. package/dist/types/src/TextList/TextList.d.ts +2 -1
  153. package/dist/types/src/ThumbnailList/ThumbnailList.d.ts +2 -1
  154. package/dist/types/src/Toast/Toast.d.ts +2 -1
  155. package/dist/types/src/Typography/Typography.d.ts +3 -3
  156. package/dist/types/src/Typography/TypographyGestureDetector.d.ts +2 -1
  157. package/dist/types/src/utils/test/MockSafeAreaProvider.d.ts +1 -1
  158. package/package.json +26 -15
  159. package/src/ActionItem/ActionItem.tsx +1 -1
  160. package/src/ActionItem/ActionItemGroup.tsx +1 -3
  161. package/src/ActionItem/components/ActionItemContainer.tsx +1 -1
  162. package/src/ActionLabel/ActionLabel.test.tsx +12 -0
  163. package/src/ActionLabel/ActionLabel.tsx +3 -3
  164. package/src/ActionLabel/__snapshots__/ActionLabel.test.tsx.snap +66 -0
  165. package/src/ActivityIndicator/ActivityIndicator.tsx +1 -3
  166. package/src/AtlantisContext/AtlantisContext.test.tsx +1 -1
  167. package/src/AtlantisThemeContext/AtlantisThemeContext.test.tsx +5 -5
  168. package/src/AutoLink/AutoLink.test.tsx +2 -4
  169. package/src/AutoLink/AutoLink.tsx +1 -1
  170. package/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.tsx +1 -1
  171. package/src/AutoLink/components/Link/Link.tsx +1 -5
  172. package/src/Banner/Banner.test.tsx +12 -0
  173. package/src/Banner/Banner.tsx +4 -2
  174. package/src/Banner/components/BannerIcon/BannerIcon.style.ts +3 -0
  175. package/src/Banner/components/BannerIcon/BannerIcon.tsx +1 -1
  176. package/src/Banner/types.ts +1 -1
  177. package/src/BottomSheet/BottomSheet.stories.tsx +128 -0
  178. package/src/BottomSheet/BottomSheet.style.ts +7 -14
  179. package/src/BottomSheet/BottomSheet.test.tsx +34 -39
  180. package/src/BottomSheet/BottomSheet.tsx +112 -92
  181. package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.tsx +1 -1
  182. package/src/BottomSheet/hooks/useBottomSheetBackHandler.test.ts +90 -0
  183. package/src/BottomSheet/hooks/useBottomSheetBackHandler.ts +41 -0
  184. package/src/Button/Button.tsx +1 -1
  185. package/src/Button/components/InternalButtonLoading/InternalButtonLoading.tsx +1 -2
  186. package/src/ButtonGroup/ButtonGroup.test.tsx +13 -11
  187. package/src/ButtonGroup/ButtonGroup.tsx +2 -2
  188. package/src/ButtonGroup/ButtonGroupAction.tsx +4 -4
  189. package/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.tsx +2 -2
  190. package/src/Card/Card.tsx +1 -1
  191. package/src/Card/components/InternalCardHeader.tsx +1 -1
  192. package/src/Checkbox/Checkbox.test.tsx +118 -1
  193. package/src/Checkbox/Checkbox.tsx +2 -2
  194. package/src/Checkbox/CheckboxGroup.test.tsx +3 -7
  195. package/src/Checkbox/CheckboxGroup.tsx +2 -2
  196. package/src/Chip/Chip.style.ts +1 -1
  197. package/src/Chip/Chip.tsx +20 -2
  198. package/src/Content/Content.tsx +7 -2
  199. package/src/Content/ContentHorizontal.style.ts +20 -0
  200. package/src/Content/ContentSpaceAround.style.ts +20 -0
  201. package/src/Content/ContentVertical.style.ts +20 -0
  202. package/src/ContentOverlay/ContentOverlay.test.tsx +34 -27
  203. package/src/ContentOverlay/ContentOverlay.tsx +7 -7
  204. package/src/ContentOverlay/UNSAFE_WrappedModalize.tsx +41 -0
  205. package/src/ContentOverlay/hooks/useKeyboardVisibility.test.ts +7 -7
  206. package/src/ContentOverlay/hooks/useViewLayoutHeight.test.ts +1 -1
  207. package/src/Disclosure/Disclosure.tsx +1 -1
  208. package/src/Divider/Divider.tsx +1 -1
  209. package/src/EmptyState/EmptyState.test.tsx +29 -42
  210. package/src/EmptyState/EmptyState.tsx +1 -1
  211. package/src/ErrorMessageWrapper/ErrorMessageWrapper.tsx +1 -1
  212. package/src/ErrorMessageWrapper/context/ErrorMessageProvider.tsx +3 -5
  213. package/src/ErrorMessageWrapper/context/types.ts +1 -1
  214. package/src/Flex/Flex.tsx +2 -2
  215. package/src/Form/Form.test.tsx +145 -2
  216. package/src/Form/Form.tsx +8 -1
  217. package/src/Form/components/FormActionBar/FormActionBar.tsx +3 -3
  218. package/src/Form/components/FormBody/FormBody.tsx +3 -3
  219. package/src/Form/components/FormCache/FormCache.tsx +5 -4
  220. package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +1 -1
  221. package/src/Form/components/FormMask/FormMask.tsx +1 -1
  222. package/src/Form/components/FormMessage/FormMessage.test.tsx +40 -27
  223. package/src/Form/components/FormMessage/FormMessage.tsx +1 -1
  224. package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +1 -1
  225. package/src/Form/components/FormMessageBanner/FormMessageBanner.tsx +1 -3
  226. package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +2 -2
  227. package/src/Form/components/FormSaveButton/FormSaveButton.tsx +1 -1
  228. package/src/Form/context/AtlantisFormContext.test.tsx +1 -1
  229. package/src/Form/context/AtlantisFormContext.tsx +1 -0
  230. package/src/Form/context/types.ts +5 -4
  231. package/src/Form/hooks/useFormViewRefs.ts +4 -5
  232. package/src/Form/hooks/useInternalForm.ts +14 -6
  233. package/src/Form/hooks/useScrollToError/useScrollToError.test.tsx +2 -1
  234. package/src/Form/types.ts +14 -8
  235. package/src/FormField/FormField.tsx +1 -1
  236. package/src/FormatFile/FormatFile.test.tsx +21 -21
  237. package/src/FormatFile/FormatFile.tsx +3 -3
  238. package/src/FormatFile/components/ErrorIcon/ErrorIcon.tsx +1 -1
  239. package/src/FormatFile/components/FileView/FileView.tsx +1 -1
  240. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +14 -14
  241. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +2 -2
  242. package/src/FormatFile/components/MediaView/MediaView.test.tsx +283 -0
  243. package/src/FormatFile/components/MediaView/MediaView.tsx +28 -7
  244. package/src/FormatFile/components/ProgressBar/ProgressBar.tsx +1 -1
  245. package/src/FormatFile/utils/createUseCreateThumbnail.ts +1 -1
  246. package/src/Glimmer/Glimmer.test.tsx +2 -2
  247. package/src/Heading/Heading.test.tsx +13 -0
  248. package/src/Heading/Heading.tsx +3 -3
  249. package/src/Heading/__snapshots__/Heading.test.tsx.snap +65 -0
  250. package/src/Icon/Icon.tsx +1 -1
  251. package/src/Icon/__snapshots__/Icon.test.tsx.snap +7 -0
  252. package/src/IconButton/IconButton.tsx +1 -1
  253. package/src/InputCurrency/InputCurrency.tsx +72 -58
  254. package/src/InputDate/InputDate.tsx +7 -3
  255. package/src/InputEmail/InputEmail.tsx +15 -8
  256. package/src/InputFieldWrapper/InputFieldWrapper.style.ts +1 -1
  257. package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +48 -1
  258. package/src/InputFieldWrapper/InputFieldWrapper.tsx +39 -29
  259. package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +1 -1
  260. package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +8 -16
  261. package/src/InputFieldWrapper/components/Prefix/Prefix.tsx +8 -6
  262. package/src/InputFieldWrapper/components/Suffix/Suffix.test.tsx +2 -4
  263. package/src/InputFieldWrapper/components/Suffix/Suffix.tsx +8 -6
  264. package/src/InputNumber/InputNumber.tsx +11 -7
  265. package/src/InputPassword/InputPassword.tsx +1 -1
  266. package/src/InputPressable/InputPressable.style.ts +4 -0
  267. package/src/InputPressable/InputPressable.test.tsx +75 -1
  268. package/src/InputPressable/InputPressable.tsx +34 -8
  269. package/src/InputSearch/InputSearch.tsx +2 -1
  270. package/src/InputSearch/components/FilterButton.tsx +1 -1
  271. package/src/InputText/InputText.style.ts +5 -0
  272. package/src/InputText/InputText.test.tsx +190 -1
  273. package/src/InputText/InputText.tsx +37 -20
  274. package/src/InputText/context/InputAccessoriesProvider.tsx +1 -1
  275. package/src/InputTime/InputTime.tsx +7 -3
  276. package/src/Menu/Menu.tsx +3 -3
  277. package/src/Menu/components/MenuOption/MenuOption.tsx +1 -1
  278. package/src/Menu/components/Overlay/Overlay.tsx +1 -1
  279. package/src/Menu/types.ts +7 -1
  280. package/src/ProgressBar/ProgressBar.test.tsx +109 -0
  281. package/src/ProgressBar/ProgressBar.tsx +18 -2
  282. package/src/ProgressBar/ProgressBarInner.tsx +8 -11
  283. package/src/ProgressBar/ProgressBarStepped.tsx +12 -1
  284. package/src/ProgressBar/__snapshots__/ProgressBar.test.tsx.snap +14 -0
  285. package/src/ProgressBar/types.ts +22 -0
  286. package/src/Select/Select.style.ts +1 -0
  287. package/src/Select/Select.tsx +2 -2
  288. package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.tsx +1 -1
  289. package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.tsx +1 -1
  290. package/src/Select/components/SelectInternalPicker/SelectInternalPicker.tsx +1 -1
  291. package/src/Select/components/SelectPressable/SelectPressable.tsx +1 -4
  292. package/src/StatusLabel/StatusLabel.style.ts +2 -2
  293. package/src/StatusLabel/StatusLabel.tsx +1 -1
  294. package/src/StatusLabel/__snapshots__/StatusLabel.test.tsx.snap +14 -14
  295. package/src/Switch/Switch.tsx +1 -1
  296. package/src/Switch/components/BaseSwitch/BaseSwitch.tsx +8 -2
  297. package/src/Text/Text.test.tsx +10 -0
  298. package/src/Text/Text.tsx +3 -3
  299. package/src/Text/__snapshots__/Text.test.tsx.snap +66 -0
  300. package/src/TextList/TextList.tsx +1 -1
  301. package/src/ThumbnailList/ThumbnailList.test.tsx +5 -5
  302. package/src/ThumbnailList/ThumbnailList.tsx +1 -1
  303. package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +199 -1
  304. package/src/Toast/Toast.tsx +2 -2
  305. package/src/Typography/Typography.test.tsx +61 -0
  306. package/src/Typography/Typography.tsx +25 -9
  307. package/src/Typography/TypographyGestureDetector.tsx +1 -3
  308. package/src/Typography/__snapshots__/Typography.test.tsx.snap +222 -0
  309. package/src/hooks/useAtlantisI18n/locales/en.json +1 -0
  310. package/src/hooks/useAtlantisI18n/locales/es.json +1 -0
  311. package/src/hooks/useFormController.ts +7 -14
  312. package/src/utils/test/MockSafeAreaProvider.tsx +1 -1
  313. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
- import { render, renderHook } from "@testing-library/react-native";
2
+ import { render, renderHook, screen } from "@testing-library/react-native";
3
3
  import type { TextStyle } from "react-native";
4
4
  import type { ReactTestInstance } from "react-test-renderer";
5
+ import { Path } from "react-native-svg";
5
6
  import type { PrefixIconProps, PrefixLabelProps } from "./Prefix";
6
7
  import {
7
8
  PrefixIcon,
@@ -12,9 +13,6 @@ import {
12
13
  import { useTypographyStyles } from "../../../Typography";
13
14
  import { useStyles } from "../../InputFieldWrapper.style";
14
15
  import { tokens } from "../../../utils/design";
15
- import * as IconComponent from "../../../Icon/Icon";
16
-
17
- const iconSpy = jest.spyOn(IconComponent, "Icon");
18
16
 
19
17
  const mockLabel = "$";
20
18
 
@@ -32,7 +30,7 @@ beforeAll(() => {
32
30
  function setupLabel({
33
31
  disabled = false,
34
32
  focused = false,
35
- hasMiniLabel = false,
33
+ miniLabelActive = false,
36
34
  inputInvalid = false,
37
35
  label = mockLabel,
38
36
  styleOverride,
@@ -41,7 +39,7 @@ function setupLabel({
41
39
  <PrefixLabel
42
40
  disabled={disabled}
43
41
  focused={focused}
44
- hasMiniLabel={hasMiniLabel}
42
+ miniLabelActive={miniLabelActive}
45
43
  inputInvalid={inputInvalid}
46
44
  label={label}
47
45
  styleOverride={styleOverride}
@@ -52,7 +50,6 @@ function setupLabel({
52
50
  function setupIcon({
53
51
  disabled = false,
54
52
  focused = false,
55
- hasMiniLabel = false,
56
53
  inputInvalid = false,
57
54
  icon = "invoice",
58
55
  }: Partial<PrefixIconProps>) {
@@ -60,7 +57,6 @@ function setupIcon({
60
57
  <PrefixIcon
61
58
  disabled={disabled}
62
59
  focused={focused}
63
- hasMiniLabel={hasMiniLabel}
64
60
  inputInvalid={inputInvalid}
65
61
  icon={icon}
66
62
  />,
@@ -152,7 +148,7 @@ describe("Prefix", () => {
152
148
 
153
149
  it("updates the position of the label when a value is entered", () => {
154
150
  const tree = setupLabel({
155
- hasMiniLabel: true,
151
+ miniLabelActive: true,
156
152
  });
157
153
  const prefixLabel = tree.getByTestId(prefixLabelTestId);
158
154
  const labelWrapper = prefixLabel.children[0] as ReactTestInstance;
@@ -180,13 +176,9 @@ describe("Prefix", () => {
180
176
  setupIcon({
181
177
  disabled: true,
182
178
  });
183
- expect(iconSpy).toHaveBeenCalledWith(
184
- {
185
- customColor: tokens["color-disabled"],
186
- name: "invoice",
187
- },
188
- {},
189
- );
179
+ const icon = screen.getByTestId("invoice");
180
+ const path = icon.findByType(Path);
181
+ expect(path.props.fill).toEqual(tokens["color-disabled"]);
190
182
  });
191
183
  });
192
184
 
@@ -11,7 +11,7 @@ import { useStyles } from "../../InputFieldWrapper.style";
11
11
  export interface PrefixLabelProps {
12
12
  readonly focused: boolean;
13
13
  readonly disabled?: boolean;
14
- readonly hasMiniLabel: boolean;
14
+ readonly miniLabelActive: boolean;
15
15
  readonly inputInvalid: boolean;
16
16
  readonly label: string;
17
17
  readonly styleOverride?: StyleProp<TextStyle>;
@@ -23,11 +23,11 @@ export const prefixIconTestId = "ATL-InputFieldWrapper-PrefixIcon";
23
23
  export function PrefixLabel({
24
24
  focused,
25
25
  disabled,
26
- hasMiniLabel,
26
+ miniLabelActive,
27
27
  inputInvalid,
28
28
  label,
29
29
  styleOverride,
30
- }: PrefixLabelProps): JSX.Element {
30
+ }: PrefixLabelProps) {
31
31
  const styles = useStyles();
32
32
  const typographyStyles = useTypographyStyles();
33
33
 
@@ -41,7 +41,10 @@ export function PrefixLabel({
41
41
  testID={prefixLabelTestId}
42
42
  >
43
43
  <View
44
- style={[styles.prefixLabel, hasMiniLabel && styles.fieldAffixMiniLabel]}
44
+ style={[
45
+ styles.prefixLabel,
46
+ miniLabelActive && styles.fieldAffixMiniLabel,
47
+ ]}
45
48
  >
46
49
  {!styleOverride ? (
47
50
  <Text variation={disabled ? "disabled" : "base"}>{label}</Text>
@@ -67,7 +70,6 @@ export function PrefixLabel({
67
70
  export interface PrefixIconProps {
68
71
  readonly focused: boolean;
69
72
  readonly disabled?: boolean;
70
- readonly hasMiniLabel: boolean;
71
73
  readonly inputInvalid?: boolean;
72
74
  readonly icon: IconNames;
73
75
  readonly styleOverride?: StyleProp<ViewStyle>;
@@ -78,7 +80,7 @@ export function PrefixIcon({
78
80
  disabled,
79
81
  inputInvalid,
80
82
  icon,
81
- }: PrefixIconProps): JSX.Element {
83
+ }: PrefixIconProps) {
82
84
  const styles = useStyles();
83
85
  const { tokens } = useAtlantisTheme();
84
86
 
@@ -10,7 +10,7 @@ const mockLabel = "$";
10
10
  function setupLabel({
11
11
  disabled = false,
12
12
  focused = false,
13
- hasMiniLabel = false,
13
+ miniLabelActive = false,
14
14
  inputInvalid = false,
15
15
  label = mockLabel,
16
16
  styleOverride,
@@ -19,7 +19,7 @@ function setupLabel({
19
19
  <SuffixLabel
20
20
  disabled={disabled}
21
21
  focused={focused}
22
- hasMiniLabel={hasMiniLabel}
22
+ miniLabelActive={miniLabelActive}
23
23
  inputInvalid={inputInvalid}
24
24
  label={label}
25
25
  styleOverride={styleOverride}
@@ -30,7 +30,6 @@ function setupLabel({
30
30
  function setupIcon({
31
31
  disabled = false,
32
32
  focused = false,
33
- hasMiniLabel = false,
34
33
  inputInvalid = false,
35
34
  icon = "invoice",
36
35
  }: Partial<SuffixIconProps>) {
@@ -38,7 +37,6 @@ function setupIcon({
38
37
  <SuffixIcon
39
38
  disabled={disabled}
40
39
  focused={focused}
41
- hasMiniLabel={hasMiniLabel}
42
40
  inputInvalid={inputInvalid}
43
41
  icon={icon}
44
42
  />,
@@ -11,7 +11,7 @@ import { useStyles } from "../../InputFieldWrapper.style";
11
11
  export interface SuffixLabelProps {
12
12
  readonly focused: boolean;
13
13
  readonly disabled?: boolean;
14
- readonly hasMiniLabel: boolean;
14
+ readonly miniLabelActive: boolean;
15
15
  readonly inputInvalid?: boolean;
16
16
  readonly label: string;
17
17
  readonly hasLeftMargin?: boolean;
@@ -24,12 +24,12 @@ export const suffixIconTestId = "ATL-InputFieldWrapper-SuffixIcon";
24
24
  export function SuffixLabel({
25
25
  focused,
26
26
  disabled,
27
- hasMiniLabel,
27
+ miniLabelActive,
28
28
  inputInvalid,
29
29
  label,
30
30
  hasLeftMargin = true,
31
31
  styleOverride,
32
- }: SuffixLabelProps): JSX.Element {
32
+ }: SuffixLabelProps) {
33
33
  const styles = useStyles();
34
34
  const typographyStyles = useTypographyStyles();
35
35
 
@@ -44,7 +44,10 @@ export function SuffixLabel({
44
44
  ]}
45
45
  >
46
46
  <View
47
- style={[styles.suffixLabel, hasMiniLabel && styles.fieldAffixMiniLabel]}
47
+ style={[
48
+ styles.suffixLabel,
49
+ miniLabelActive && styles.fieldAffixMiniLabel,
50
+ ]}
48
51
  >
49
52
  {!styleOverride ? (
50
53
  <Text variation={disabled ? "disabled" : "base"}>{label}</Text>
@@ -70,7 +73,6 @@ export function SuffixLabel({
70
73
  export interface SuffixIconProps {
71
74
  readonly focused: boolean;
72
75
  readonly disabled?: boolean;
73
- readonly hasMiniLabel: boolean;
74
76
  readonly inputInvalid?: boolean;
75
77
  readonly icon: IconNames;
76
78
  readonly hasLeftMargin?: boolean;
@@ -84,7 +86,7 @@ export function SuffixIcon({
84
86
  icon,
85
87
  hasLeftMargin = false,
86
88
  onPress,
87
- }: SuffixIconProps): JSX.Element {
89
+ }: SuffixIconProps) {
88
90
  const styles = useStyles();
89
91
  const { tokens } = useAtlantisTheme();
90
92
 
@@ -46,6 +46,16 @@ function InputNumberInternal(props: InputNumberProps, ref: Ref<InputTextRef>) {
46
46
  const { inputTransform: convertToString, outputTransform: convertToNumber } =
47
47
  useNumberTransform(props.value);
48
48
 
49
+ const defaultValidations = {
50
+ pattern: {
51
+ value: NUMBER_VALIDATION_REGEX,
52
+ message: t("errors.notANumber"),
53
+ },
54
+ } as const;
55
+ const mergedValidations = props.validations
56
+ ? Object.assign({}, defaultValidations, props.validations)
57
+ : defaultValidations;
58
+
49
59
  return (
50
60
  <InputText
51
61
  {...props}
@@ -58,13 +68,7 @@ function InputNumberInternal(props: InputNumberProps, ref: Ref<InputTextRef>) {
58
68
  value={props.value?.toString()}
59
69
  defaultValue={props.defaultValue?.toString()}
60
70
  onChangeText={handleChange}
61
- validations={{
62
- pattern: {
63
- value: NUMBER_VALIDATION_REGEX,
64
- message: t("errors.notANumber"),
65
- },
66
- ...props.validations,
67
- }}
71
+ validations={mergedValidations}
68
72
  />
69
73
  );
70
74
  }
@@ -23,7 +23,7 @@ export interface InputPasswordProps
23
23
  function InputPasswordInternal(
24
24
  { usePrivacyEye = true, ...props }: InputPasswordProps,
25
25
  ref: Ref<InputTextRef>,
26
- ): JSX.Element {
26
+ ) {
27
27
  const { t } = useAtlantisI18n();
28
28
  const [passwordHidden, setPasswordHidden] = useState(true);
29
29
  const [privacyEye, setPrivacyEye] = useState<IconNames>("eye");
@@ -28,5 +28,9 @@ export const useStyles = buildThemedStyles(tokens => {
28
28
  inputInvalid: {
29
29
  borderColor: tokens["color-critical"],
30
30
  },
31
+
32
+ withoutMiniLabel: {
33
+ paddingTop: tokens["space-base"] + tokens["space-smallest"],
34
+ },
31
35
  };
32
36
  });
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { fireEvent, render } from "@testing-library/react-native";
2
+ import { fireEvent, render, screen } from "@testing-library/react-native";
3
3
  import { InputPressable } from ".";
4
4
  import type { InputFieldWrapperProps } from "../InputFieldWrapper";
5
5
 
@@ -120,6 +120,80 @@ describe("InputPressable", () => {
120
120
  expect(getByText(value, { includeHiddenElements: true })).toBeDefined();
121
121
  });
122
122
  });
123
+
124
+ describe("showMiniLabel", () => {
125
+ it("defaults to true", () => {
126
+ const props = { placeholder: "placeholder", value: "value" };
127
+ render(<InputPressable {...props} />);
128
+ expect(
129
+ screen.getByText("placeholder", { includeHiddenElements: true }),
130
+ ).toBeDefined();
131
+ expect(MockInputFieldWrapper).toHaveBeenCalledWith(
132
+ expect.objectContaining({
133
+ placeholderMode: "mini",
134
+ }),
135
+ );
136
+ });
137
+
138
+ describe("when true", () => {
139
+ it("renders the placeholder in its normal position when the input has no value", () => {
140
+ const props = { showMiniLabel: true, placeholder: "placeholder" };
141
+ render(<InputPressable {...props} />);
142
+ expect(
143
+ screen.getByText("placeholder", { includeHiddenElements: true }),
144
+ ).toBeDefined();
145
+ expect(MockInputFieldWrapper).toHaveBeenCalledWith(
146
+ expect.objectContaining({
147
+ placeholderMode: "normal",
148
+ }),
149
+ );
150
+ });
151
+
152
+ it("renders the placeholder as a mini label when the input has a value", () => {
153
+ const props = {
154
+ showMiniLabel: true,
155
+ placeholder: "placeholder",
156
+ value: "value",
157
+ };
158
+ render(<InputPressable {...props} />);
159
+ expect(
160
+ screen.getByText("placeholder", { includeHiddenElements: true }),
161
+ ).toBeDefined();
162
+ expect(MockInputFieldWrapper).toHaveBeenCalledWith(
163
+ expect.objectContaining({
164
+ placeholderMode: "mini",
165
+ }),
166
+ );
167
+ });
168
+ });
169
+
170
+ describe("when false", () => {
171
+ it("renders the placeholder in its normal position when the input has no value", () => {
172
+ const props = { showMiniLabel: false, placeholder: "placeholder" };
173
+ render(<InputPressable {...props} />);
174
+ expect(
175
+ screen.getByText("placeholder", { includeHiddenElements: true }),
176
+ ).toBeDefined();
177
+ expect(MockInputFieldWrapper).toHaveBeenCalledWith(
178
+ expect.objectContaining({
179
+ placeholderMode: "normal",
180
+ }),
181
+ );
182
+ });
183
+
184
+ it("does not render the placeholder when the input has a value", () => {
185
+ const props = {
186
+ showMiniLabel: false,
187
+ placeholder: "placeholder",
188
+ value: "value",
189
+ };
190
+ render(<InputPressable {...props} />);
191
+ expect(
192
+ screen.queryByText("placeholder", { includeHiddenElements: true }),
193
+ ).toBeNull();
194
+ });
195
+ });
196
+ });
123
197
  });
124
198
 
125
199
  describe("accessibilityLabel", () => {
@@ -1,5 +1,5 @@
1
1
  import type { Ref } from "react";
2
- import React, { forwardRef, useEffect, useState } from "react";
2
+ import React, { forwardRef } from "react";
3
3
  import type { IconNames } from "@jobber/design";
4
4
  import type { FieldError } from "react-hook-form";
5
5
  import { Text as NativeText, Pressable } from "react-native";
@@ -7,6 +7,7 @@ import type { Clearable } from "@jobber/hooks";
7
7
  import { useShowClear } from "@jobber/hooks";
8
8
  import type { XOR } from "ts-xor";
9
9
  import { useStyles } from "./InputPressable.style";
10
+ import type { InputFieldWrapperProps } from "../InputFieldWrapper";
10
11
  import { InputFieldWrapper, useCommonInputStyles } from "../InputFieldWrapper";
11
12
 
12
13
  interface BasicSuffix {
@@ -51,6 +52,15 @@ export interface InputPressableProps {
51
52
  */
52
53
  readonly invalid?: boolean | string;
53
54
 
55
+ /**
56
+ * Controls the visibility of the mini label that appears inside the input
57
+ * when a value is entered. By default, the placeholder text moves up to
58
+ * become a mini label. Set to false to disable this behavior.
59
+ *
60
+ * @default true
61
+ */
62
+ readonly showMiniLabel?: boolean;
63
+
54
64
  /**
55
65
  * Callback that is called when the text input is focused
56
66
  * @param event
@@ -105,6 +115,7 @@ export function InputPressableInternal(
105
115
  disabled,
106
116
  invalid,
107
117
  error,
118
+ showMiniLabel = true,
108
119
  onPress,
109
120
  accessibilityLabel,
110
121
  accessibilityHint,
@@ -115,13 +126,10 @@ export function InputPressableInternal(
115
126
  focused,
116
127
  }: InputPressableProps,
117
128
  ref: Ref<InputPressableRef>,
118
- ): JSX.Element {
129
+ ) {
119
130
  const hasValue = !!value;
120
- const [hasMiniLabel, setHasMiniLabel] = useState(Boolean(value));
121
131
 
122
- useEffect(() => {
123
- setHasMiniLabel(Boolean(value));
124
- }, [value]);
132
+ const placeholderMode = getPlaceholderMode(showMiniLabel, value);
125
133
 
126
134
  const showClear = useShowClear({
127
135
  clearable,
@@ -139,7 +147,7 @@ export function InputPressableInternal(
139
147
  prefix={prefix}
140
148
  suffix={suffix}
141
149
  hasValue={hasValue}
142
- hasMiniLabel={hasMiniLabel}
150
+ placeholderMode={placeholderMode}
143
151
  focused={focused}
144
152
  error={error}
145
153
  invalid={invalid}
@@ -160,7 +168,8 @@ export function InputPressableInternal(
160
168
  style={[
161
169
  commonInputStyles.input,
162
170
  styles.inputPressableStyles,
163
- !hasMiniLabel && commonInputStyles.inputEmpty,
171
+ placeholderMode === "normal" && commonInputStyles.inputEmpty,
172
+ placeholderMode === "hidden" && styles.withoutMiniLabel,
164
173
  disabled && commonInputStyles.inputDisabled,
165
174
  (Boolean(invalid) || error) && styles.inputInvalid,
166
175
  ]}
@@ -176,3 +185,20 @@ export function InputPressableInternal(
176
185
  </InputFieldWrapper>
177
186
  );
178
187
  }
188
+
189
+ function getPlaceholderMode(
190
+ isMiniLabelAllowed: boolean,
191
+ internalValue: string | undefined,
192
+ ): InputFieldWrapperProps["placeholderMode"] {
193
+ const hasValue = Boolean(internalValue);
194
+
195
+ if (hasValue) {
196
+ if (isMiniLabelAllowed) {
197
+ return "mini";
198
+ } else {
199
+ return "hidden";
200
+ }
201
+ } else {
202
+ return "normal";
203
+ }
204
+ }
@@ -1,7 +1,7 @@
1
1
  import type { Ref } from "react";
2
2
  import React, { forwardRef, useEffect } from "react";
3
3
  import { View } from "react-native";
4
- import { useDebounce } from "@jobber/hooks/useDebounce";
4
+ import { useDebounce } from "@jobber/hooks";
5
5
  import { styles } from "./InputSearch.style";
6
6
  import type { InputTextProps, InputTextRef } from "../InputText";
7
7
  import { InputText } from "../InputText";
@@ -16,6 +16,7 @@ export interface InputSearchProps
16
16
  | "autoFocus"
17
17
  | "placeholder"
18
18
  | "prefix"
19
+ | "showMiniLabel"
19
20
  > {
20
21
  /**
21
22
  * A callback function that handles the update of the new value of the property value.
@@ -10,7 +10,7 @@ interface FilterButtonProps {
10
10
  export function FilterButton({
11
11
  accessibilityLabel,
12
12
  onClick,
13
- }: FilterButtonProps): JSX.Element {
13
+ }: FilterButtonProps) {
14
14
  return (
15
15
  <IconButton
16
16
  onPress={() => {
@@ -27,5 +27,10 @@ export const useStyles = buildThemedStyles(tokens => {
27
27
  paddingTop:
28
28
  (typographyStyles.defaultSize.fontSize || 0) + tokens["space-smallest"],
29
29
  },
30
+
31
+ multilineWithoutMiniLabel: {
32
+ paddingTop: tokens["space-base"] + tokens["space-smallest"],
33
+ paddingBottom: tokens["space-base"] + tokens["space-smallest"],
34
+ },
30
35
  };
31
36
  });
@@ -4,10 +4,11 @@ import {
4
4
  fireEvent,
5
5
  render,
6
6
  renderHook,
7
+ screen,
7
8
  waitFor,
8
9
  } from "@testing-library/react-native";
9
10
  import type { TextStyle } from "react-native";
10
- import { Platform } from "react-native";
11
+ import { Button, Platform } from "react-native";
11
12
  import { FormProvider, useForm } from "react-hook-form";
12
13
  import type { InputTextProps } from "./InputText";
13
14
  import { InputText } from "./InputText";
@@ -548,6 +549,194 @@ describe("InputText", () => {
548
549
  expect(styleOverride.inputText.color).toEqual(flattenedStyle.color);
549
550
  });
550
551
  });
552
+
553
+ describe("showMiniLabel", () => {
554
+ it("defaults to true", () => {
555
+ const props = { placeholder: "placeholder", value: "value" };
556
+ renderInputText(props);
557
+ expect(
558
+ screen.getByText("placeholder", { includeHiddenElements: true }),
559
+ ).toBeDefined();
560
+ expect(MockInputFieldWrapper).toHaveBeenCalledWith(
561
+ expect.objectContaining({
562
+ placeholderMode: "mini",
563
+ }),
564
+ );
565
+ });
566
+
567
+ describe("when true", () => {
568
+ it("renders the placeholder in its normal position when the input has no value", () => {
569
+ const props = { showMiniLabel: true, placeholder: "placeholder" };
570
+ renderInputText(props);
571
+ expect(
572
+ screen.getByText("placeholder", { includeHiddenElements: true }),
573
+ ).toBeDefined();
574
+ expect(MockInputFieldWrapper).toHaveBeenCalledWith(
575
+ expect.objectContaining({
576
+ placeholderMode: "normal",
577
+ }),
578
+ );
579
+ });
580
+
581
+ it("renders the placeholder as a mini label when the input has a value", () => {
582
+ const props = {
583
+ showMiniLabel: true,
584
+ placeholder: "placeholder",
585
+ value: "value",
586
+ };
587
+ renderInputText(props);
588
+ expect(
589
+ screen.getByText("placeholder", { includeHiddenElements: true }),
590
+ ).toBeDefined();
591
+ expect(MockInputFieldWrapper).toHaveBeenCalledWith(
592
+ expect.objectContaining({
593
+ placeholderMode: "mini",
594
+ }),
595
+ );
596
+ });
597
+ });
598
+
599
+ describe("when false", () => {
600
+ it("renders the placeholder in its normal position when the input has no value", () => {
601
+ const props = { showMiniLabel: false, placeholder: "placeholder" };
602
+ renderInputText(props);
603
+ expect(
604
+ screen.getByText("placeholder", { includeHiddenElements: true }),
605
+ ).toBeDefined();
606
+ expect(MockInputFieldWrapper).toHaveBeenCalledWith(
607
+ expect.objectContaining({
608
+ placeholderMode: "normal",
609
+ }),
610
+ );
611
+ });
612
+
613
+ it("does not render the placeholder when the input has a value", () => {
614
+ const props = {
615
+ showMiniLabel: false,
616
+ placeholder: "placeholder",
617
+ value: "value",
618
+ };
619
+ renderInputText(props);
620
+ expect(
621
+ screen.queryByText("placeholder", { includeHiddenElements: true }),
622
+ ).toBeNull();
623
+ });
624
+ });
625
+ });
626
+
627
+ describe("with FormProvider", () => {
628
+ const mockOnSubmit = jest.fn();
629
+ const inputName = "testInput";
630
+ const inputAccessibilityLabel = "Test Input";
631
+ const saveButtonText = "Save";
632
+
633
+ function FormWithProvider({
634
+ defaultValue,
635
+ }: {
636
+ readonly defaultValue?: string;
637
+ }) {
638
+ const formMethods = useForm();
639
+
640
+ return (
641
+ <FormProvider {...formMethods}>
642
+ <InputText
643
+ name={inputName}
644
+ defaultValue={defaultValue}
645
+ accessibilityLabel={inputAccessibilityLabel}
646
+ />
647
+ <Button
648
+ onPress={formMethods.handleSubmit(values => mockOnSubmit(values))}
649
+ title={saveButtonText}
650
+ accessibilityLabel={saveButtonText}
651
+ />
652
+ </FormProvider>
653
+ );
654
+ }
655
+
656
+ beforeEach(() => {
657
+ mockOnSubmit.mockClear();
658
+ });
659
+
660
+ describe("defaultValue prop sets form value", () => {
661
+ it("sets form value to string when defaultValue is provided", async () => {
662
+ const testValue = "test value";
663
+ const { getByLabelText } = render(
664
+ <FormWithProvider defaultValue={testValue} />,
665
+ );
666
+
667
+ const saveButton = getByLabelText(saveButtonText);
668
+ await waitFor(() => {
669
+ fireEvent.press(saveButton);
670
+ });
671
+
672
+ expect(mockOnSubmit).toHaveBeenCalledWith({
673
+ [inputName]: testValue,
674
+ });
675
+ });
676
+
677
+ it("sets form value to undefined when defaultValue is undefined", async () => {
678
+ const { getByLabelText } = render(<FormWithProvider />);
679
+
680
+ const saveButton = getByLabelText(saveButtonText);
681
+ await waitFor(() => {
682
+ fireEvent.press(saveButton);
683
+ });
684
+
685
+ expect(mockOnSubmit).toHaveBeenCalledWith({
686
+ [inputName]: undefined,
687
+ });
688
+ });
689
+
690
+ it("sets form value to undefined when defaultValue is empty string", async () => {
691
+ const { getByLabelText } = render(<FormWithProvider defaultValue="" />);
692
+
693
+ const saveButton = getByLabelText(saveButtonText);
694
+ await waitFor(() => {
695
+ fireEvent.press(saveButton);
696
+ });
697
+
698
+ expect(mockOnSubmit).toHaveBeenCalledWith({
699
+ [inputName]: undefined,
700
+ });
701
+ });
702
+ });
703
+
704
+ describe("input value updates form value", () => {
705
+ it("updates form value when input text is changed", async () => {
706
+ const { getByLabelText } = render(
707
+ <FormWithProvider defaultValue="initial" />,
708
+ );
709
+
710
+ const input = getByLabelText(inputAccessibilityLabel);
711
+ fireEvent.changeText(input, "new value");
712
+
713
+ const saveButton = getByLabelText(saveButtonText);
714
+ await waitFor(() => {
715
+ fireEvent.press(saveButton);
716
+ });
717
+
718
+ expect(mockOnSubmit).toHaveBeenCalledWith({
719
+ [inputName]: "new value",
720
+ });
721
+ });
722
+
723
+ it("preserves defaultValue when input is not interacted with", async () => {
724
+ const testValue = "preserved value";
725
+ const { getByLabelText } = render(
726
+ <FormWithProvider defaultValue={testValue} />,
727
+ );
728
+
729
+ const saveButton = getByLabelText(saveButtonText);
730
+ await waitFor(() => {
731
+ fireEvent.press(saveButton);
732
+ });
733
+
734
+ expect(mockOnSubmit).toHaveBeenCalledWith({
735
+ [inputName]: testValue,
736
+ });
737
+ });
738
+ });
739
+ });
551
740
  });
552
741
 
553
742
  describe("Transform", () => {