@jobber/components-native 0.36.0 → 0.37.1-JOB-70291.14

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 (320) hide show
  1. package/dist/src/AtlantisContext/AtlantisContext.js +2 -0
  2. package/dist/src/ContentOverlay/ContentOverlay.js +144 -0
  3. package/dist/src/ContentOverlay/ContentOverlay.style.js +56 -0
  4. package/dist/src/ContentOverlay/hooks/useKeyboardVisibility.js +21 -0
  5. package/dist/src/ContentOverlay/hooks/useViewLayoutHeight.js +10 -0
  6. package/dist/src/ContentOverlay/index.js +1 -0
  7. package/dist/src/ContentOverlay/messages.js +8 -0
  8. package/dist/src/ContentOverlay/types.js +1 -0
  9. package/dist/src/Disclosure/Disclosure.js +50 -0
  10. package/dist/src/Disclosure/Disclosure.style.js +21 -0
  11. package/dist/src/Disclosure/constants.js +1 -0
  12. package/dist/src/Disclosure/index.js +1 -0
  13. package/dist/src/Form/Form.js +187 -0
  14. package/dist/src/Form/Form.style.js +33 -0
  15. package/dist/src/Form/components/FormActionBar/FormActionBar.js +21 -0
  16. package/dist/src/Form/components/FormActionBar/FormActionBar.style.js +5 -0
  17. package/dist/src/Form/components/FormActionBar/index.js +1 -0
  18. package/dist/src/Form/components/FormBody/FormBody.js +20 -0
  19. package/dist/src/Form/components/FormBody/FormBody.style.js +26 -0
  20. package/dist/src/Form/components/FormBody/index.js +1 -0
  21. package/dist/src/Form/components/FormCache/FormCache.js +34 -0
  22. package/dist/src/Form/components/FormErrorBanner/FormErrorBanner.js +21 -0
  23. package/dist/src/Form/components/FormErrorBanner/index.js +1 -0
  24. package/dist/src/Form/components/FormErrorBanner/messages.js +13 -0
  25. package/dist/src/Form/components/FormMask/FormMask.js +11 -0
  26. package/dist/src/Form/components/FormMask/FormMask.style.js +15 -0
  27. package/dist/src/Form/components/FormMask/index.js +1 -0
  28. package/dist/src/Form/components/FormMessage/FormMessage.js +48 -0
  29. package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.js +28 -0
  30. package/dist/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.js +17 -0
  31. package/dist/src/Form/components/FormMessage/components/InternalFormMessage/index.js +1 -0
  32. package/dist/src/Form/components/FormMessage/components/InternalFormMessage/messages.js +8 -0
  33. package/dist/src/Form/components/FormMessage/index.js +1 -0
  34. package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.js +15 -0
  35. package/dist/src/Form/components/FormMessageBanner/index.js +1 -0
  36. package/dist/src/Form/components/FormSaveButton/FormSaveButton.js +69 -0
  37. package/dist/src/Form/components/FormSaveButton/index.js +1 -0
  38. package/dist/src/Form/components/FormSaveButton/messages.js +8 -0
  39. package/dist/src/Form/constants.js +2 -0
  40. package/dist/src/Form/context/AtlantisFormContext.js +16 -0
  41. package/dist/src/Form/context/index.js +1 -0
  42. package/dist/src/Form/context/types.js +1 -0
  43. package/dist/src/Form/hooks/useFormViewRefs.js +14 -0
  44. package/dist/src/Form/hooks/useInternalForm.js +37 -0
  45. package/dist/src/Form/hooks/useOfflineHandler.js +24 -0
  46. package/dist/src/Form/hooks/useSaveButtonPosition.js +25 -0
  47. package/dist/src/Form/hooks/useScreenInformation.js +15 -0
  48. package/dist/src/Form/hooks/useScrollToError/index.js +1 -0
  49. package/dist/src/Form/hooks/useScrollToError/useScrollToError.js +63 -0
  50. package/dist/src/Form/index.js +4 -0
  51. package/dist/src/Form/messages.js +28 -0
  52. package/dist/src/Form/types.js +10 -0
  53. package/dist/src/FormatFile/FormatFile.js +114 -0
  54. package/dist/src/FormatFile/FormatFile.style.js +16 -0
  55. package/dist/src/FormatFile/components/ErrorIcon/ErrorIcon.js +8 -0
  56. package/dist/src/FormatFile/components/ErrorIcon/ErrorIcon.style.js +10 -0
  57. package/dist/src/FormatFile/components/ErrorIcon/index.js +1 -0
  58. package/dist/src/FormatFile/components/FileView/FileView.js +67 -0
  59. package/dist/src/FormatFile/components/FileView/FileView.style.js +64 -0
  60. package/dist/src/FormatFile/components/FileView/index.js +1 -0
  61. package/dist/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.js +22 -0
  62. package/dist/src/FormatFile/components/FormatFileBottomSheet/index.js +1 -0
  63. package/dist/src/FormatFile/components/FormatFileBottomSheet/messages.js +13 -0
  64. package/dist/src/FormatFile/components/MediaView/MediaView.js +56 -0
  65. package/dist/src/FormatFile/components/MediaView/MediaView.style.js +27 -0
  66. package/dist/src/FormatFile/components/MediaView/index.js +1 -0
  67. package/dist/src/FormatFile/components/ProgressBar/ProgressBar.js +29 -0
  68. package/dist/src/FormatFile/components/ProgressBar/ProgressBar.style.js +15 -0
  69. package/dist/src/FormatFile/components/ProgressBar/index.js +1 -0
  70. package/dist/src/FormatFile/components/_mocks/mockFiles.js +78 -0
  71. package/dist/src/FormatFile/constants.js +14 -0
  72. package/dist/src/FormatFile/context/FormatFileContext.js +8 -0
  73. package/dist/src/FormatFile/context/types.js +1 -0
  74. package/dist/src/FormatFile/index.js +1 -0
  75. package/dist/src/FormatFile/messages.js +23 -0
  76. package/dist/src/FormatFile/types.js +8 -0
  77. package/dist/src/FormatFile/utils/computeA11yLabel.js +12 -0
  78. package/dist/src/FormatFile/utils/createUseCreateThumbnail.js +22 -0
  79. package/dist/src/FormatFile/utils/index.js +1 -0
  80. package/dist/src/InputDate/InputDate.js +76 -0
  81. package/dist/src/InputDate/index.js +1 -0
  82. package/dist/src/InputDate/messages.js +8 -0
  83. package/dist/src/Menu/Menu.js +67 -0
  84. package/dist/src/Menu/Menu.style.js +6 -0
  85. package/dist/src/Menu/components/MenuOption/MenuOption.js +25 -0
  86. package/dist/src/Menu/components/MenuOption/MenuOption.style.js +10 -0
  87. package/dist/src/Menu/components/MenuOption/index.js +1 -0
  88. package/dist/src/Menu/components/Overlay/Overlay.js +9 -0
  89. package/dist/src/Menu/components/Overlay/Overlay.style.js +6 -0
  90. package/dist/src/Menu/components/Overlay/index.js +1 -0
  91. package/dist/src/Menu/index.js +1 -0
  92. package/dist/src/Menu/messages.js +8 -0
  93. package/dist/src/Menu/types.js +1 -0
  94. package/dist/src/Menu/utils.js +84 -0
  95. package/dist/src/ThumbnailList/ThumbnailList.js +35 -0
  96. package/dist/src/ThumbnailList/ThumbnailList.style.js +49 -0
  97. package/dist/src/ThumbnailList/index.js +1 -0
  98. package/dist/src/index.js +7 -0
  99. package/dist/src/utils/test/wait.js +1 -1
  100. package/dist/tsconfig.tsbuildinfo +1 -1
  101. package/dist/types/src/AtlantisContext/AtlantisContext.d.ts +7 -1
  102. package/dist/types/src/ContentOverlay/ContentOverlay.d.ts +6 -0
  103. package/dist/types/src/ContentOverlay/ContentOverlay.style.d.ts +60 -0
  104. package/dist/types/src/ContentOverlay/hooks/useKeyboardVisibility.d.ts +6 -0
  105. package/dist/types/src/ContentOverlay/hooks/useViewLayoutHeight.d.ts +6 -0
  106. package/dist/types/src/ContentOverlay/index.d.ts +2 -0
  107. package/dist/types/src/ContentOverlay/messages.d.ts +7 -0
  108. package/dist/types/src/ContentOverlay/types.d.ts +87 -0
  109. package/dist/types/src/Disclosure/Disclosure.d.ts +35 -0
  110. package/dist/types/src/Disclosure/Disclosure.style.d.ts +19 -0
  111. package/dist/types/src/Disclosure/constants.d.ts +1 -0
  112. package/dist/types/src/Disclosure/index.d.ts +1 -0
  113. package/dist/types/src/Form/Form.d.ts +4 -0
  114. package/dist/types/src/Form/Form.style.d.ts +31 -0
  115. package/dist/types/src/Form/components/FormActionBar/FormActionBar.d.ts +13 -0
  116. package/dist/types/src/Form/components/FormActionBar/FormActionBar.style.d.ts +15 -0
  117. package/dist/types/src/Form/components/FormActionBar/index.d.ts +2 -0
  118. package/dist/types/src/Form/components/FormBody/FormBody.d.ts +10 -0
  119. package/dist/types/src/Form/components/FormBody/FormBody.style.d.ts +24 -0
  120. package/dist/types/src/Form/components/FormBody/index.d.ts +1 -0
  121. package/dist/types/src/Form/components/FormCache/FormCache.d.ts +10 -0
  122. package/dist/types/src/Form/components/FormErrorBanner/FormErrorBanner.d.ts +3 -0
  123. package/dist/types/src/Form/components/FormErrorBanner/index.d.ts +1 -0
  124. package/dist/types/src/Form/components/FormErrorBanner/messages.d.ts +12 -0
  125. package/dist/types/src/Form/components/FormMask/FormMask.d.ts +2 -0
  126. package/dist/types/src/Form/components/FormMask/FormMask.style.d.ts +13 -0
  127. package/dist/types/src/Form/components/FormMask/index.d.ts +1 -0
  128. package/dist/types/src/Form/components/FormMessage/FormMessage.d.ts +20 -0
  129. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.d.ts +8 -0
  130. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.d.ts +20 -0
  131. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/index.d.ts +1 -0
  132. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/messages.d.ts +7 -0
  133. package/dist/types/src/Form/components/FormMessage/index.d.ts +1 -0
  134. package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.d.ts +7 -0
  135. package/dist/types/src/Form/components/FormMessageBanner/index.d.ts +1 -0
  136. package/dist/types/src/Form/components/FormSaveButton/FormSaveButton.d.ts +3 -0
  137. package/dist/types/src/Form/components/FormSaveButton/index.d.ts +1 -0
  138. package/dist/types/src/Form/components/FormSaveButton/messages.d.ts +7 -0
  139. package/dist/types/src/Form/constants.d.ts +2 -0
  140. package/dist/types/src/Form/context/AtlantisFormContext.d.ts +12 -0
  141. package/dist/types/src/Form/context/index.d.ts +2 -0
  142. package/dist/types/src/Form/context/types.d.ts +26 -0
  143. package/dist/types/src/Form/hooks/useFormViewRefs.d.ts +10 -0
  144. package/dist/types/src/Form/hooks/useInternalForm.d.ts +19 -0
  145. package/dist/types/src/Form/hooks/useOfflineHandler.d.ts +1 -0
  146. package/dist/types/src/Form/hooks/useSaveButtonPosition.d.ts +12 -0
  147. package/dist/types/src/Form/hooks/useScreenInformation.d.ts +8 -0
  148. package/dist/types/src/Form/hooks/useScrollToError/index.d.ts +1 -0
  149. package/dist/types/src/Form/hooks/useScrollToError/useScrollToError.d.ts +10 -0
  150. package/dist/types/src/Form/index.d.ts +5 -0
  151. package/dist/types/src/Form/messages.d.ts +27 -0
  152. package/dist/types/src/Form/types.d.ts +199 -0
  153. package/dist/types/src/FormatFile/FormatFile.d.ts +47 -0
  154. package/dist/types/src/FormatFile/FormatFile.style.d.ts +14 -0
  155. package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.d.ts +2 -0
  156. package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.style.d.ts +8 -0
  157. package/dist/types/src/FormatFile/components/ErrorIcon/index.d.ts +1 -0
  158. package/dist/types/src/FormatFile/components/FileView/FileView.d.ts +12 -0
  159. package/dist/types/src/FormatFile/components/FileView/FileView.style.d.ts +62 -0
  160. package/dist/types/src/FormatFile/components/FileView/index.d.ts +1 -0
  161. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.d.ts +11 -0
  162. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/index.d.ts +2 -0
  163. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/messages.d.ts +12 -0
  164. package/dist/types/src/FormatFile/components/MediaView/MediaView.d.ts +12 -0
  165. package/dist/types/src/FormatFile/components/MediaView/MediaView.style.d.ts +25 -0
  166. package/dist/types/src/FormatFile/components/MediaView/index.d.ts +1 -0
  167. package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.d.ts +19 -0
  168. package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.style.d.ts +13 -0
  169. package/dist/types/src/FormatFile/components/ProgressBar/index.d.ts +1 -0
  170. package/dist/types/src/FormatFile/components/_mocks/mockFiles.d.ts +18 -0
  171. package/dist/types/src/FormatFile/constants.d.ts +6 -0
  172. package/dist/types/src/FormatFile/context/FormatFileContext.d.ts +10 -0
  173. package/dist/types/src/FormatFile/context/types.d.ts +9 -0
  174. package/dist/types/src/FormatFile/index.d.ts +3 -0
  175. package/dist/types/src/FormatFile/messages.d.ts +22 -0
  176. package/dist/types/src/FormatFile/types.d.ts +105 -0
  177. package/dist/types/src/FormatFile/utils/computeA11yLabel.d.ts +9 -0
  178. package/dist/types/src/FormatFile/utils/createUseCreateThumbnail.d.ts +5 -0
  179. package/dist/types/src/FormatFile/utils/index.d.ts +1 -0
  180. package/dist/types/src/InputCurrency/InputCurrency.d.ts +1 -1
  181. package/dist/types/src/InputDate/InputDate.d.ts +74 -0
  182. package/dist/types/src/InputDate/index.d.ts +1 -0
  183. package/dist/types/src/InputDate/messages.d.ts +7 -0
  184. package/dist/types/src/InputNumber/InputNumber.d.ts +1 -1
  185. package/dist/types/src/Menu/Menu.d.ts +3 -0
  186. package/dist/types/src/Menu/Menu.style.d.ts +18 -0
  187. package/dist/types/src/Menu/components/MenuOption/MenuOption.d.ts +3 -0
  188. package/dist/types/src/Menu/components/MenuOption/MenuOption.style.d.ts +8 -0
  189. package/dist/types/src/Menu/components/MenuOption/index.d.ts +1 -0
  190. package/dist/types/src/Menu/components/Overlay/Overlay.d.ts +3 -0
  191. package/dist/types/src/Menu/components/Overlay/Overlay.style.d.ts +12 -0
  192. package/dist/types/src/Menu/components/Overlay/index.d.ts +1 -0
  193. package/dist/types/src/Menu/index.d.ts +2 -0
  194. package/dist/types/src/Menu/messages.d.ts +7 -0
  195. package/dist/types/src/Menu/types.d.ts +22 -0
  196. package/dist/types/src/Menu/utils.d.ts +10 -0
  197. package/dist/types/src/ThumbnailList/ThumbnailList.d.ts +17 -0
  198. package/dist/types/src/ThumbnailList/ThumbnailList.style.d.ts +47 -0
  199. package/dist/types/src/ThumbnailList/index.d.ts +1 -0
  200. package/dist/types/src/index.d.ts +7 -0
  201. package/package.json +4 -2
  202. package/src/AtlantisContext/AtlantisContext.tsx +10 -1
  203. package/src/ContentOverlay/ContentOverlay.style.ts +70 -0
  204. package/src/ContentOverlay/ContentOverlay.test.tsx +371 -0
  205. package/src/ContentOverlay/ContentOverlay.tsx +295 -0
  206. package/src/ContentOverlay/hooks/useKeyboardVisibility.test.ts +42 -0
  207. package/src/ContentOverlay/hooks/useKeyboardVisibility.ts +36 -0
  208. package/src/ContentOverlay/hooks/useViewLayoutHeight.test.ts +56 -0
  209. package/src/ContentOverlay/hooks/useViewLayoutHeight.ts +18 -0
  210. package/src/ContentOverlay/index.ts +2 -0
  211. package/src/ContentOverlay/messages.ts +9 -0
  212. package/src/ContentOverlay/types.ts +96 -0
  213. package/src/Disclosure/Disclosure.style.ts +22 -0
  214. package/src/Disclosure/Disclosure.test.tsx +71 -0
  215. package/src/Disclosure/Disclosure.tsx +162 -0
  216. package/src/Disclosure/__snapshots__/Disclosure.test.tsx.snap +488 -0
  217. package/src/Disclosure/constants.ts +1 -0
  218. package/src/Disclosure/index.ts +1 -0
  219. package/src/Form/Form.style.ts +34 -0
  220. package/src/Form/Form.test.tsx +588 -0
  221. package/src/Form/Form.tsx +296 -0
  222. package/src/Form/components/FormActionBar/FormActionBar.style.ts +11 -0
  223. package/src/Form/components/FormActionBar/FormActionBar.tsx +63 -0
  224. package/src/Form/components/FormActionBar/index.ts +2 -0
  225. package/src/Form/components/FormBody/FormBody.style.ts +27 -0
  226. package/src/Form/components/FormBody/FormBody.tsx +62 -0
  227. package/src/Form/components/FormBody/index.ts +1 -0
  228. package/src/Form/components/FormCache/FormCache.tsx +50 -0
  229. package/src/Form/components/FormErrorBanner/FormErrorBanner.test.tsx +124 -0
  230. package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +34 -0
  231. package/src/Form/components/FormErrorBanner/index.ts +1 -0
  232. package/src/Form/components/FormErrorBanner/messages.ts +14 -0
  233. package/src/Form/components/FormMask/FormMask.style.tsx +16 -0
  234. package/src/Form/components/FormMask/FormMask.tsx +19 -0
  235. package/src/Form/components/FormMask/index.ts +1 -0
  236. package/src/Form/components/FormMessage/FormMessage.test.tsx +72 -0
  237. package/src/Form/components/FormMessage/FormMessage.tsx +63 -0
  238. package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.style.ts +18 -0
  239. package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +55 -0
  240. package/src/Form/components/FormMessage/components/InternalFormMessage/index.ts +1 -0
  241. package/src/Form/components/FormMessage/components/InternalFormMessage/messages.ts +10 -0
  242. package/src/Form/components/FormMessage/index.ts +1 -0
  243. package/src/Form/components/FormMessageBanner/FormMessageBanner.test.tsx +27 -0
  244. package/src/Form/components/FormMessageBanner/FormMessageBanner.tsx +33 -0
  245. package/src/Form/components/FormMessageBanner/index.ts +1 -0
  246. package/src/Form/components/FormSaveButton/FormSaveButton.test.tsx +159 -0
  247. package/src/Form/components/FormSaveButton/FormSaveButton.tsx +103 -0
  248. package/src/Form/components/FormSaveButton/index.ts +1 -0
  249. package/src/Form/components/FormSaveButton/messages.ts +9 -0
  250. package/src/Form/constants.ts +2 -0
  251. package/src/Form/context/AtlantisFormContext.test.tsx +45 -0
  252. package/src/Form/context/AtlantisFormContext.tsx +21 -0
  253. package/src/Form/context/index.ts +5 -0
  254. package/src/Form/context/types.ts +34 -0
  255. package/src/Form/hooks/useFormViewRefs.ts +23 -0
  256. package/src/Form/hooks/useInternalForm.ts +99 -0
  257. package/src/Form/hooks/useOfflineHandler.ts +36 -0
  258. package/src/Form/hooks/useSaveButtonPosition.ts +52 -0
  259. package/src/Form/hooks/useScreenInformation.ts +25 -0
  260. package/src/Form/hooks/useScrollToError/index.ts +1 -0
  261. package/src/Form/hooks/useScrollToError/useScrollToError.test.tsx +103 -0
  262. package/src/Form/hooks/useScrollToError/useScrollToError.ts +102 -0
  263. package/src/Form/index.ts +13 -0
  264. package/src/Form/messages.ts +33 -0
  265. package/src/Form/types.ts +255 -0
  266. package/src/FormatFile/FormatFile.style.ts +17 -0
  267. package/src/FormatFile/FormatFile.test.tsx +333 -0
  268. package/src/FormatFile/FormatFile.tsx +300 -0
  269. package/src/FormatFile/components/ErrorIcon/ErrorIcon.style.ts +11 -0
  270. package/src/FormatFile/components/ErrorIcon/ErrorIcon.tsx +12 -0
  271. package/src/FormatFile/components/ErrorIcon/index.ts +1 -0
  272. package/src/FormatFile/components/FileView/FileView.style.ts +65 -0
  273. package/src/FormatFile/components/FileView/FileView.tsx +134 -0
  274. package/src/FormatFile/components/FileView/index.ts +1 -0
  275. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.tsx +108 -0
  276. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +56 -0
  277. package/src/FormatFile/components/FormatFileBottomSheet/index.ts +2 -0
  278. package/src/FormatFile/components/FormatFileBottomSheet/messages.ts +14 -0
  279. package/src/FormatFile/components/MediaView/MediaView.style.ts +28 -0
  280. package/src/FormatFile/components/MediaView/MediaView.tsx +145 -0
  281. package/src/FormatFile/components/MediaView/index.ts +1 -0
  282. package/src/FormatFile/components/ProgressBar/ProgressBar.style.tsx +16 -0
  283. package/src/FormatFile/components/ProgressBar/ProgressBar.tsx +57 -0
  284. package/src/FormatFile/components/ProgressBar/index.ts +1 -0
  285. package/src/FormatFile/components/_mocks/mockFiles.ts +105 -0
  286. package/src/FormatFile/constants.ts +15 -0
  287. package/src/FormatFile/context/FormatFileContext.ts +13 -0
  288. package/src/FormatFile/context/types.ts +12 -0
  289. package/src/FormatFile/index.ts +13 -0
  290. package/src/FormatFile/messages.ts +24 -0
  291. package/src/FormatFile/types.ts +126 -0
  292. package/src/FormatFile/utils/computeA11yLabel.ts +26 -0
  293. package/src/FormatFile/utils/createUseCreateThumbnail.ts +33 -0
  294. package/src/FormatFile/utils/index.ts +1 -0
  295. package/src/InputCurrency/InputCurrency.tsx +1 -1
  296. package/src/InputDate/InputDate.test.tsx +295 -0
  297. package/src/InputDate/InputDate.tsx +231 -0
  298. package/src/InputDate/index.ts +1 -0
  299. package/src/InputDate/messages.ts +9 -0
  300. package/src/InputNumber/InputNumber.tsx +1 -1
  301. package/src/Menu/Menu.style.ts +16 -0
  302. package/src/Menu/Menu.test.tsx +201 -0
  303. package/src/Menu/Menu.tsx +116 -0
  304. package/src/Menu/components/MenuOption/MenuOption.style.tsx +11 -0
  305. package/src/Menu/components/MenuOption/MenuOption.tsx +63 -0
  306. package/src/Menu/components/MenuOption/index.ts +1 -0
  307. package/src/Menu/components/Overlay/Overlay.style.ts +13 -0
  308. package/src/Menu/components/Overlay/Overlay.tsx +16 -0
  309. package/src/Menu/components/Overlay/index.ts +1 -0
  310. package/src/Menu/index.ts +6 -0
  311. package/src/Menu/messages.ts +9 -0
  312. package/src/Menu/types.ts +25 -0
  313. package/src/Menu/utils.ts +151 -0
  314. package/src/ThumbnailList/ThumbnailList.style.ts +50 -0
  315. package/src/ThumbnailList/ThumbnailList.test.tsx +71 -0
  316. package/src/ThumbnailList/ThumbnailList.tsx +74 -0
  317. package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +154 -0
  318. package/src/ThumbnailList/index.ts +1 -0
  319. package/src/index.ts +7 -0
  320. package/src/utils/test/wait.ts +3 -1
@@ -3,6 +3,7 @@ import { createContext, useContext } from "react";
3
3
  import RNLocalize from "react-native-localize";
4
4
  import { DEFAULT_CURRENCY_SYMBOL } from "../InputCurrency/constants";
5
5
  export const defaultValues = {
6
+ dateFormat: "PP",
6
7
  // The system time is "p"
7
8
  timeFormat: "p",
8
9
  timeZone: RNLocalize.getTimeZone(),
@@ -12,6 +13,7 @@ export const defaultValues = {
12
13
  },
13
14
  floatSeparators: { group: ",", decimal: "." },
14
15
  currencySymbol: DEFAULT_CURRENCY_SYMBOL,
16
+ headerHeight: 0,
15
17
  };
16
18
  export const AtlantisContext = createContext(defaultValues);
17
19
  export function useAtlantisContext() {
@@ -0,0 +1,144 @@
1
+ import React, { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, useState, } from "react";
2
+ import { Modalize } from "react-native-modalize";
3
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
4
+ import { AccessibilityInfo, Platform, View, findNodeHandle, useWindowDimensions, } from "react-native";
5
+ import { Portal } from "react-native-portalize";
6
+ import { useIntl } from "react-intl";
7
+ import { useKeyboardVisibility } from "./hooks/useKeyboardVisibility";
8
+ import { styles } from "./ContentOverlay.style";
9
+ import { messages } from "./messages";
10
+ import { useViewLayoutHeight } from "./hooks/useViewLayoutHeight";
11
+ import { useIsScreenReaderEnabled } from "../hooks";
12
+ import { IconButton } from "../IconButton";
13
+ import { tokens } from "../utils/design";
14
+ import { Heading } from "../Heading";
15
+ export const ContentOverlay = forwardRef(ContentOverlayPortal);
16
+ const ContentOverlayModal = forwardRef(ContentOverlayInternal);
17
+ // eslint-disable-next-line max-statements
18
+ function ContentOverlayInternal({ children, title, accessibilityLabel, fullScreen = false, showDismiss = false, isDraggable = true, adjustToContentHeight = false, keyboardShouldPersistTaps = false, keyboardAvoidingBehavior, scrollEnabled = false, modalBackgroundColor = "surface", onClose, onOpen, onBeforeExit, loading = false, avoidKeyboardLikeIOS, }, ref) {
19
+ isDraggable = onBeforeExit ? false : isDraggable;
20
+ const isCloseableOnOverlayTap = onBeforeExit ? false : true;
21
+ const { formatMessage } = useIntl();
22
+ const { width: windowWidth, height: windowHeight } = useWindowDimensions();
23
+ const insets = useSafeAreaInsets();
24
+ const [position, setPosition] = useState("initial");
25
+ const isScreenReaderEnabled = useIsScreenReaderEnabled();
26
+ const isFullScreenOrTopPosition = fullScreen || (!adjustToContentHeight && position === "top");
27
+ const shouldShowDismiss = showDismiss || isScreenReaderEnabled || isFullScreenOrTopPosition;
28
+ const [showHeaderShadow, setShowHeaderShadow] = useState(false);
29
+ const overlayHeader = useRef();
30
+ const internalRef = useRef();
31
+ const [modalizeMethods, setModalizeMethods] = useState();
32
+ const callbackInternalRef = useCallback((instance) => {
33
+ if (instance && !internalRef.current) {
34
+ internalRef.current = instance;
35
+ setModalizeMethods(instance);
36
+ }
37
+ }, []);
38
+ const refMethods = useMemo(() => {
39
+ if (!(modalizeMethods === null || modalizeMethods === void 0 ? void 0 : modalizeMethods.open) || !(modalizeMethods === null || modalizeMethods === void 0 ? void 0 : modalizeMethods.close)) {
40
+ return {};
41
+ }
42
+ return {
43
+ open: modalizeMethods === null || modalizeMethods === void 0 ? void 0 : modalizeMethods.open,
44
+ close: modalizeMethods === null || modalizeMethods === void 0 ? void 0 : modalizeMethods.close,
45
+ };
46
+ }, [modalizeMethods]);
47
+ const { keyboardHeight } = useKeyboardVisibility();
48
+ useImperativeHandle(ref, () => refMethods, [refMethods]);
49
+ const { handleLayout: handleChildrenLayout, height: childrenHeight, heightKnown: childrenHeightKnown, } = useViewLayoutHeight();
50
+ const { handleLayout: handleHeaderLayout, height: headerHeight, heightKnown: headerHeightKnown, } = useViewLayoutHeight();
51
+ const snapPoint = useMemo(() => {
52
+ if (fullScreen || !isDraggable || adjustToContentHeight) {
53
+ return undefined;
54
+ }
55
+ const overlayHeight = headerHeight + childrenHeight;
56
+ if (overlayHeight >= windowHeight) {
57
+ return undefined;
58
+ }
59
+ return overlayHeight;
60
+ }, [
61
+ fullScreen,
62
+ isDraggable,
63
+ adjustToContentHeight,
64
+ headerHeight,
65
+ childrenHeight,
66
+ windowHeight,
67
+ ]);
68
+ const modalStyle = [
69
+ styles.modal,
70
+ windowWidth > 640 ? styles.modalForLargeScreens : undefined,
71
+ { backgroundColor: getModalBackgroundColor(modalBackgroundColor) },
72
+ keyboardHeight > 0 && { marginBottom: 0 },
73
+ ];
74
+ const renderedChildren = renderChildren();
75
+ const renderedHeader = renderHeader();
76
+ const onCloseController = () => {
77
+ var _a;
78
+ if (!onBeforeExit) {
79
+ (_a = internalRef.current) === null || _a === void 0 ? void 0 : _a.close();
80
+ return true;
81
+ }
82
+ else {
83
+ onBeforeExit();
84
+ return false;
85
+ }
86
+ };
87
+ return (React.createElement(React.Fragment, null,
88
+ headerHeightKnown && childrenHeightKnown && (React.createElement(Modalize, { ref: callbackInternalRef, overlayStyle: styles.overlay, handleStyle: styles.handle, handlePosition: "inside", modalStyle: modalStyle, modalTopOffset: tokens["space-larger"], snapPoint: snapPoint, closeSnapPointStraightEnabled: false, withHandle: isDraggable, panGestureEnabled: isDraggable, adjustToContentHeight: adjustToContentHeight, disableScrollIfPossible: !adjustToContentHeight, onClose: onClose, onOpen: onOpen, keyboardAvoidingBehavior: keyboardAvoidingBehavior, avoidKeyboardLikeIOS: avoidKeyboardLikeIOS, childrenStyle: styles.childrenStyle, onBackButtonPress: onCloseController, closeOnOverlayTap: isCloseableOnOverlayTap, onOpened: () => {
89
+ if (overlayHeader.current) {
90
+ const reactTag = findNodeHandle(overlayHeader.current);
91
+ if (reactTag) {
92
+ AccessibilityInfo.setAccessibilityFocus(reactTag);
93
+ }
94
+ }
95
+ }, scrollViewProps: {
96
+ scrollEnabled,
97
+ showsVerticalScrollIndicator: false,
98
+ stickyHeaderIndices: Platform.OS === "android" ? [0] : undefined,
99
+ onScroll: handleOnScroll,
100
+ keyboardShouldPersistTaps: keyboardShouldPersistTaps
101
+ ? "handled"
102
+ : "never",
103
+ }, HeaderComponent: Platform.OS === "ios" ? renderedHeader : undefined, onPositionChange: setPosition },
104
+ Platform.OS === "android" ? renderedHeader : undefined,
105
+ renderedChildren)),
106
+ !childrenHeightKnown && (React.createElement(View, { style: [styles.hiddenContent, modalStyle] }, renderedChildren)),
107
+ !headerHeightKnown && (React.createElement(View, { style: [styles.hiddenContent, modalStyle] }, renderedHeader))));
108
+ function renderHeader() {
109
+ const closeOverlayA11YLabel = formatMessage(messages.closeOverlayA11YLabel, {
110
+ title: title,
111
+ });
112
+ const headerStyles = [
113
+ styles.header,
114
+ showHeaderShadow && styles.headerShadow,
115
+ { backgroundColor: getModalBackgroundColor(modalBackgroundColor) },
116
+ ];
117
+ return (React.createElement(View, { onLayout: handleHeaderLayout, testID: "ATL-Overlay-Header" },
118
+ React.createElement(View, { style: headerStyles },
119
+ React.createElement(View, { style: showDismiss ? styles.titleWithDismiss : styles.titleWithoutDimiss },
120
+ React.createElement(Heading, { level: "subtitle", variation: loading ? "subdued" : "heading" }, title)),
121
+ shouldShowDismiss && (React.createElement(View, { style: styles.dismissButton,
122
+ // @ts-expect-error tsc-ci
123
+ ref: overlayHeader, accessibilityLabel: accessibilityLabel || closeOverlayA11YLabel, accessible: true },
124
+ React.createElement(IconButton, { name: "cross", customColor: loading ? tokens["color-disabled"] : tokens["color-heading"], onPress: () => onCloseController(), accessibilityLabel: closeOverlayA11YLabel, testID: "ATL-Overlay-CloseButton" }))))));
125
+ }
126
+ function renderChildren() {
127
+ return (React.createElement(View, { style: { paddingBottom: insets.bottom }, onLayout: handleChildrenLayout, testID: "ATL-Overlay-Children" }, children));
128
+ }
129
+ function handleOnScroll({ nativeEvent, }) {
130
+ setShowHeaderShadow(nativeEvent.contentOffset.y > 0);
131
+ }
132
+ function getModalBackgroundColor(variation) {
133
+ switch (variation) {
134
+ case "surface":
135
+ return tokens["color-surface"];
136
+ case "background":
137
+ return tokens["color-surface--background"];
138
+ }
139
+ }
140
+ }
141
+ function ContentOverlayPortal(modalProps, ref) {
142
+ return (React.createElement(Portal, null,
143
+ React.createElement(ContentOverlayModal, Object.assign({ ref: ref }, modalProps))));
144
+ }
@@ -0,0 +1,56 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { tokens } from "../utils/design";
3
+ const modalBorderRadius = tokens["radius-larger"];
4
+ const titleOffsetFromHandle = tokens["space-small"] + tokens["space-smallest"];
5
+ export const styles = StyleSheet.create({
6
+ handle: {
7
+ width: tokens["space-largest"],
8
+ height: tokens["space-smaller"] + tokens["space-smallest"],
9
+ backgroundColor: tokens["color-border"],
10
+ top: tokens["space-small"],
11
+ borderRadius: tokens["radius-circle"],
12
+ },
13
+ overlay: {
14
+ backgroundColor: tokens["color-overlay"],
15
+ },
16
+ modal: {
17
+ borderTopLeftRadius: modalBorderRadius,
18
+ borderTopRightRadius: modalBorderRadius,
19
+ },
20
+ modalForLargeScreens: {
21
+ width: 640,
22
+ alignSelf: "center",
23
+ },
24
+ header: {
25
+ flexDirection: "row",
26
+ backgroundColor: tokens["color-surface"],
27
+ paddingTop: titleOffsetFromHandle,
28
+ zIndex: tokens["elevation-base"],
29
+ borderTopLeftRadius: modalBorderRadius,
30
+ borderTopRightRadius: modalBorderRadius,
31
+ height: tokens["space-extravagant"],
32
+ },
33
+ headerShadow: Object.assign({}, tokens["shadow-base"]),
34
+ childrenStyle: {
35
+ // We need to explicity lower the zIndex because otherwise, the modal content slides over the header shadow.
36
+ zIndex: -1,
37
+ },
38
+ dismissButton: {
39
+ alignItems: "center",
40
+ },
41
+ hiddenContent: {
42
+ opacity: 0,
43
+ },
44
+ titleWithoutDimiss: {
45
+ flex: 1,
46
+ flexDirection: "row",
47
+ justifyContent: "center",
48
+ paddingTop: tokens["space-base"],
49
+ },
50
+ titleWithDismiss: {
51
+ flex: 1,
52
+ justifyContent: "center",
53
+ paddingLeft: tokens["space-base"],
54
+ paddingRight: tokens["space-smaller"],
55
+ },
56
+ });
@@ -0,0 +1,21 @@
1
+ import { useEffect, useState } from "react";
2
+ import { Keyboard } from "react-native";
3
+ export function useKeyboardVisibility() {
4
+ const [isKeyboardVisible, setKeyboardVisible] = useState(false);
5
+ const [keyboardHeight, setKeyboardHeight] = useState(0);
6
+ useEffect(() => {
7
+ const keyboardDidShowListener = Keyboard.addListener("keyboardDidShow", (event) => {
8
+ setKeyboardVisible(true);
9
+ setKeyboardHeight(event.endCoordinates.height);
10
+ });
11
+ const keyboardDidHideListener = Keyboard.addListener("keyboardDidHide", () => {
12
+ setKeyboardVisible(false);
13
+ setKeyboardHeight(0);
14
+ });
15
+ return () => {
16
+ keyboardDidHideListener.remove();
17
+ keyboardDidShowListener.remove();
18
+ };
19
+ }, []);
20
+ return { isKeyboardVisible, keyboardHeight };
21
+ }
@@ -0,0 +1,10 @@
1
+ import { useState } from "react";
2
+ export function useViewLayoutHeight() {
3
+ const [heightKnown, setHeightKnown] = useState(false);
4
+ const [height, setHeight] = useState(0);
5
+ const handleLayout = ({ nativeEvent }) => {
6
+ setHeightKnown(true);
7
+ setHeight(nativeEvent.layout.height);
8
+ };
9
+ return { handleLayout, height, heightKnown };
10
+ }
@@ -0,0 +1 @@
1
+ export { ContentOverlay } from "./ContentOverlay";
@@ -0,0 +1,8 @@
1
+ import { defineMessages } from "react-intl";
2
+ export const messages = defineMessages({
3
+ closeOverlayA11YLabel: {
4
+ id: "closeOverlayA11yLabel",
5
+ defaultMessage: "Close {title} modal",
6
+ description: "Accessibility label for button to close the overlay modal",
7
+ },
8
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,50 @@
1
+ import React, { useState } from "react";
2
+ import { ScrollView, TouchableOpacity, View, } from "react-native";
3
+ import Reanimated, { Easing, useAnimatedStyle, useSharedValue, withTiming, } from "react-native-reanimated";
4
+ import { EASE_CUBIC_IN_OUT } from "./constants";
5
+ import { styles } from "./Disclosure.style";
6
+ import { tokens } from "../utils/design";
7
+ import { Icon } from "../Icon";
8
+ const ReanimatedView = Reanimated.createAnimatedComponent(View);
9
+ const ReanimatedScrollView = Reanimated.createAnimatedComponent(ScrollView);
10
+ export function Disclosure({ content, header, open, onToggle, isEmpty, animationDuration = tokens["timing-slowest"], }) {
11
+ return (React.createElement(View, { style: styles.container },
12
+ React.createElement(DisclosureHeader, Object.assign({}, { header, onToggle, isEmpty, open, animationDuration })),
13
+ React.createElement(DisclosureContent, Object.assign({}, { content, open, animationDuration }))));
14
+ }
15
+ function DisclosureHeader({ header, onToggle, isEmpty, open, animationDuration, }) {
16
+ const rotateZ = useSharedValue(0);
17
+ rotateZ.value = withTiming(open ? 0 : -180, {
18
+ easing: Easing.bezier(...EASE_CUBIC_IN_OUT),
19
+ duration: animationDuration,
20
+ });
21
+ const animatedStyle = useAnimatedStyle(() => {
22
+ return {
23
+ transform: [{ rotateZ: `${rotateZ.value}deg` }],
24
+ };
25
+ });
26
+ return (React.createElement(TouchableOpacity, { activeOpacity: tokens["opacity-pressed"], onPress: onToggle, disabled: isEmpty },
27
+ React.createElement(View, { style: styles.headerContainer },
28
+ header,
29
+ !isEmpty && (React.createElement(ReanimatedView, { style: [animatedStyle] },
30
+ React.createElement(Icon, { name: "arrowUp", color: "grey" }))))));
31
+ }
32
+ function DisclosureContent({ content, open, animationDuration, }) {
33
+ const [maxHeight, setMaxHeight] = useState(0);
34
+ const height = useSharedValue(0);
35
+ const onContentLayoutChange = (event) => {
36
+ const newHeight = event.nativeEvent.layout.height;
37
+ setMaxHeight(newHeight);
38
+ };
39
+ height.value = withTiming(open ? maxHeight : 0, {
40
+ duration: animationDuration,
41
+ easing: Easing.bezier(...EASE_CUBIC_IN_OUT),
42
+ });
43
+ const animatedStyle = useAnimatedStyle(() => {
44
+ return {
45
+ height: height.value,
46
+ };
47
+ }, []);
48
+ return (React.createElement(ReanimatedScrollView, { scrollEnabled: false, showsHorizontalScrollIndicator: false, showsVerticalScrollIndicator: false, style: [styles.contentContainer, animatedStyle] },
49
+ React.createElement(View, { testID: "content", onLayout: onContentLayoutChange }, content)));
50
+ }
@@ -0,0 +1,21 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { tokens } from "../utils/design";
3
+ export const styles = StyleSheet.create({
4
+ container: {
5
+ width: "100%",
6
+ },
7
+ headerContainer: {
8
+ flexDirection: "row",
9
+ alignItems: "flex-start",
10
+ justifyContent: "space-between",
11
+ },
12
+ countColumn: {
13
+ paddingRight: tokens["space-base"],
14
+ },
15
+ titleContainer: {
16
+ flexDirection: "row",
17
+ },
18
+ contentContainer: {
19
+ paddingTop: tokens["space-small"],
20
+ },
21
+ });
@@ -0,0 +1 @@
1
+ export const EASE_CUBIC_IN_OUT = [0.645, 0.045, 0.355, 1.0];
@@ -0,0 +1 @@
1
+ export { Disclosure } from "./Disclosure";
@@ -0,0 +1,187 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __rest = (this && this.__rest) || function (s, e) {
11
+ var t = {};
12
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
+ t[p] = s[p];
14
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
+ t[p[i]] = s[p[i]];
18
+ }
19
+ return t;
20
+ };
21
+ import React, { useState } from "react";
22
+ import { FormProvider } from "react-hook-form";
23
+ import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
24
+ import { Keyboard, Platform, View, findNodeHandle, } from "react-native";
25
+ import { styles } from "./Form.style";
26
+ import { FormErrorBanner } from "./components/FormErrorBanner";
27
+ import { KEYBOARD_SAVE_BUTTON_DISTANCE } from "./constants";
28
+ import { FormMessageBanner } from "./components/FormMessageBanner";
29
+ import { FormSubmitErrorType, } from "./types";
30
+ import { FormMask } from "./components/FormMask";
31
+ import { useInternalForm } from "./hooks/useInternalForm";
32
+ import { useFormViewRefs } from "./hooks/useFormViewRefs";
33
+ import { useScreenInformation } from "./hooks/useScreenInformation";
34
+ import { FormMessage } from "./components/FormMessage";
35
+ import { FormBody, useBottomPadding } from "./components/FormBody";
36
+ import { useOfflineHandler } from "./hooks/useOfflineHandler";
37
+ import { useScrollToError } from "./hooks/useScrollToError";
38
+ import { FormSaveButton } from "./components/FormSaveButton";
39
+ import { useSaveButtonPosition } from "./hooks/useSaveButtonPosition";
40
+ import { FormCache } from "./components/FormCache/FormCache";
41
+ import { InputAccessoriesProvider } from "../InputText";
42
+ import { tokens } from "../utils/design";
43
+ import { ErrorMessageProvider } from "../ErrorMessageWrapper";
44
+ export function Form(_a) {
45
+ var { initialLoading } = _a, rest = __rest(_a, ["initialLoading"]);
46
+ const child = initialLoading ? React.createElement(FormMask, null) : React.createElement(InternalForm, Object.assign({}, rest));
47
+ return (React.createElement(InputAccessoriesProvider, null,
48
+ React.createElement(ErrorMessageProvider, null, child)));
49
+ }
50
+ // eslint-disable-next-line max-statements
51
+ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSubmitSuccess, bannerErrors, bannerMessages, initialValues, mode = "onTouched", reValidateMode = "onChange", formRef, saveButtonLabel, renderStickySection, localCacheKey, localCacheExclude, localCacheId, secondaryActions, saveButtonOffset, showStickySaveButton = false, renderFooter, }) {
52
+ var _a;
53
+ const { scrollViewRef, bottomViewRef, scrollToTop } = useFormViewRefs();
54
+ const [saveButtonHeight, setSaveButtonHeight] = useState(0);
55
+ const [messageBannerHeight, setMessageBannerHeight] = useState(0);
56
+ const { formMethods, handleSubmit, isSubmitting, removeListenerRef, setLocalCache, } = useInternalForm({
57
+ mode,
58
+ reValidateMode,
59
+ initialValues,
60
+ formRef,
61
+ localCacheKey,
62
+ localCacheExclude,
63
+ localCacheId,
64
+ scrollViewRef,
65
+ saveButtonHeight,
66
+ messageBannerHeight,
67
+ });
68
+ const { windowHeight, headerHeight } = useScreenInformation();
69
+ const [keyboardHeight, setKeyboardHeight] = useState(0);
70
+ const [keyboardScreenY, setKeyboardScreenY] = useState(0);
71
+ const [formContentHeight, setFormContentHeight] = useState(0);
72
+ const [isBottomSheetOpen, setIsBottomSheetOpen] = useState(false);
73
+ const paddingBottom = useBottomPadding();
74
+ const { saveButtonPosition } = useSaveButtonPosition({
75
+ formContentHeight,
76
+ isBottomSheetOpen,
77
+ showStickySaveButton,
78
+ keyboardHeight,
79
+ keyboardScreenY,
80
+ });
81
+ const [isSecondaryActionLoading, setIsSecondaryActionLoading] = useState(false);
82
+ const extraViewHeight = paddingBottom + KEYBOARD_SAVE_BUTTON_DISTANCE;
83
+ const calculatedKeyboardHeight = keyboardHeight - extraViewHeight;
84
+ useScrollToError({
85
+ formState: formMethods.formState,
86
+ refNode: findNodeHandle(scrollViewRef.current),
87
+ setFocus: formMethods.setFocus,
88
+ scrollToPosition: (_a = scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollToPosition,
89
+ });
90
+ const handleOfflineSubmit = useOfflineHandler();
91
+ const keyboardProps = Platform.select({
92
+ ios: {
93
+ onKeyboardWillHide: handleKeyboardHide,
94
+ onKeyboardWillShow: handleKeyboardShow,
95
+ },
96
+ android: {
97
+ onKeyboardDidHide: handleKeyboardHide,
98
+ onKeyboardDidShow: handleKeyboardShow,
99
+ },
100
+ });
101
+ const onLayout = (event) => {
102
+ setMessageBannerHeight(event.nativeEvent.layout.height);
103
+ };
104
+ return (React.createElement(FormProvider, Object.assign({}, formMethods),
105
+ React.createElement(React.Fragment, null,
106
+ (isSubmitting || isSecondaryActionLoading) && React.createElement(FormMask, null),
107
+ React.createElement(FormCache, { localCacheKey: localCacheKey, localCacheExclude: localCacheExclude, setLocalCache: setLocalCache }),
108
+ React.createElement(FormBody, { keyboardHeight: calculateSaveButtonOffset(), submit: handleSubmit(internalSubmit), isFormSubmitting: isSubmitting, saveButtonLabel: saveButtonLabel, shouldRenderActionBar: saveButtonPosition === "sticky", renderStickySection: renderStickySection, secondaryActions: secondaryActions, setSecondaryActionLoading: setIsSecondaryActionLoading, setSaveButtonHeight: setSaveButtonHeight, saveButtonOffset: saveButtonOffset },
109
+ React.createElement(KeyboardAwareScrollView, Object.assign({ enableResetScrollToCoords: false, enableAutomaticScroll: true, keyboardOpeningTime: Platform.OS === "ios" ? tokens["timing-slowest"] : 0, keyboardShouldPersistTaps: "handled", ref: scrollViewRef }, keyboardProps, { extraHeight: headerHeight, contentContainerStyle: !keyboardHeight && styles.scrollContentContainer }),
110
+ React.createElement(View, { onLayout: ({ nativeEvent }) => {
111
+ setFormContentHeight(nativeEvent.layout.height);
112
+ } },
113
+ React.createElement(View, { onLayout: onLayout },
114
+ React.createElement(FormMessageBanner, { bannerMessages: bannerMessages }),
115
+ React.createElement(FormErrorBanner, { networkError: bannerErrors === null || bannerErrors === void 0 ? void 0 : bannerErrors.networkError, bannerError: bannerErrors === null || bannerErrors === void 0 ? void 0 : bannerErrors.bannerError })),
116
+ React.createElement(View, { style: styles.formChildContainer },
117
+ React.createElement(React.Fragment, null,
118
+ React.createElement(View, { style: styles.formContent }, children),
119
+ saveButtonPosition === "inline" && (React.createElement(View, { style: styles.fixedSaveButton }, renderStickySection ? (renderStickySection(handleSubmit(internalSubmit), saveButtonLabel, isSubmitting)) : (React.createElement(FormSaveButton, { primaryAction: handleSubmit(internalSubmit), label: saveButtonLabel, loading: isSubmitting, secondaryActions: secondaryActions, setSecondaryActionLoading: setIsSecondaryActionLoading, onOpenBottomSheet: () => setIsBottomSheetOpen(true), onCloseBottomSheet: () => setIsBottomSheetOpen(false) })))),
120
+ renderFooter))),
121
+ React.createElement(View, { style: styles.safeArea, ref: bottomViewRef })))),
122
+ React.createElement(FormMessage, null)));
123
+ function handleKeyboardShow(frames) {
124
+ setKeyboardScreenY(frames.endCoordinates.screenY);
125
+ setKeyboardHeight(frames.endCoordinates.height);
126
+ }
127
+ function handleKeyboardHide() {
128
+ var _a;
129
+ (_a = bottomViewRef === null || bottomViewRef === void 0 ? void 0 : bottomViewRef.current) === null || _a === void 0 ? void 0 : _a.measureInWindow(
130
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
131
+ (_x, y, _width, _height) => {
132
+ var _a;
133
+ // This fixes extra whitespace below the form if it was scrolled down while the keyboard was open
134
+ // i.e. a View below the form is higher than the bottom of the window
135
+ if (y < windowHeight) {
136
+ (_a = scrollViewRef === null || scrollViewRef === void 0 ? void 0 : scrollViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollToEnd();
137
+ }
138
+ });
139
+ setKeyboardHeight(0);
140
+ setKeyboardScreenY(0);
141
+ }
142
+ function internalSubmit(data) {
143
+ return __awaiter(this, void 0, void 0, function* () {
144
+ let performSubmit = true;
145
+ if (onBeforeSubmit) {
146
+ performSubmit = yield onBeforeSubmit(data);
147
+ }
148
+ if (performSubmit) {
149
+ Keyboard.dismiss();
150
+ return onSubmit(data)
151
+ .then((result) => {
152
+ var _a;
153
+ (_a = removeListenerRef.current) === null || _a === void 0 ? void 0 : _a.call(removeListenerRef);
154
+ onSubmitSuccess(result);
155
+ })
156
+ .catch(handleSubmitCatch);
157
+ }
158
+ });
159
+ }
160
+ function handleSubmitCatch(error) {
161
+ // Scroll to top of form to see error
162
+ scrollToTop();
163
+ onSubmitError(error);
164
+ if ((error === null || error === void 0 ? void 0 : error.errorType) === FormSubmitErrorType.NetworkError) {
165
+ // @ts-expect-error We are making the form submission fail so that we can
166
+ // prevent the isSubmitSuccess to be true
167
+ formMethods.setError("offline", "Error saving form.");
168
+ handleOfflineSubmit(handleRetry, clearFormErrors)();
169
+ }
170
+ }
171
+ function clearFormErrors() {
172
+ // @ts-expect-error We are clearing the error that we previously set
173
+ // when the form had no internet connection
174
+ formMethods.clearErrors("offline");
175
+ }
176
+ function handleRetry() {
177
+ clearFormErrors();
178
+ return handleSubmit(internalSubmit)();
179
+ }
180
+ function calculateSaveButtonOffset() {
181
+ if (saveButtonOffset) {
182
+ // Included the space-base because it's the padding of the FormActionBar
183
+ return calculatedKeyboardHeight - saveButtonOffset + tokens["space-base"];
184
+ }
185
+ return calculatedKeyboardHeight;
186
+ }
187
+ }
@@ -0,0 +1,33 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { tokens } from "../utils/design";
3
+ export const styles = StyleSheet.create({
4
+ container: {
5
+ flex: 1,
6
+ flexGrow: 1,
7
+ width: "100%",
8
+ },
9
+ safeArea: {
10
+ backgroundColor: tokens["color-surface"],
11
+ },
12
+ scrollContentContainer: {
13
+ flexGrow: 1,
14
+ },
15
+ scrollView: {
16
+ flexGrow: 1,
17
+ },
18
+ formChildContainer: {
19
+ flexGrow: 1,
20
+ justifyContent: "flex-start",
21
+ },
22
+ formContent: {
23
+ paddingVertical: tokens["space-small"],
24
+ },
25
+ fixedSaveButton: {
26
+ padding: tokens["space-base"],
27
+ backgroundColor: tokens["color-surface"],
28
+ },
29
+ activityIndicator: {
30
+ marginVertical: tokens["space-base"],
31
+ flex: 1,
32
+ },
33
+ });
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { StyleSheet, View } from "react-native";
3
+ import Reanimated from "react-native-reanimated";
4
+ import { styles } from "./FormActionBar.style";
5
+ import { FormSaveButton } from "../FormSaveButton";
6
+ const ReanimatedView = Reanimated.createAnimatedComponent(View);
7
+ export function FormActionBar({ keyboardHeight, submit, isFormSubmitting, saveButtonLabel, renderStickySection, setSaveButtonHeight, secondaryActions, setSecondaryActionLoading, }) {
8
+ const buttonStyle = StyleSheet.flatten([
9
+ styles.saveButton,
10
+ {
11
+ position: keyboardHeight > 0 ? "absolute" : "relative",
12
+ bottom: 0,
13
+ },
14
+ ]);
15
+ const onLayout = (event) => {
16
+ setSaveButtonHeight && setSaveButtonHeight(event.nativeEvent.layout.height);
17
+ };
18
+ return (
19
+ //@ts-expect-error tsc-ci
20
+ React.createElement(ReanimatedView, { style: buttonStyle, onLayout: onLayout }, renderStickySection ? (renderStickySection(submit, saveButtonLabel, isFormSubmitting)) : (React.createElement(FormSaveButton, { setSecondaryActionLoading: setSecondaryActionLoading, primaryAction: submit, loading: isFormSubmitting, label: saveButtonLabel, secondaryActions: secondaryActions }))));
21
+ }
@@ -0,0 +1,5 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { tokens } from "../../../utils/design";
3
+ export const styles = StyleSheet.create({
4
+ saveButton: Object.assign({ padding: tokens["space-base"], backgroundColor: tokens["color-surface"], width: "100%" }, tokens["shadow-high"]),
5
+ });
@@ -0,0 +1 @@
1
+ export { FormActionBar } from "./FormActionBar";
@@ -0,0 +1,20 @@
1
+ import React, { useMemo } from "react";
2
+ import { View } from "react-native";
3
+ import { styles } from "./FormBody.style";
4
+ import { useScreenInformation } from "../../hooks/useScreenInformation";
5
+ import { FormActionBar } from "../FormActionBar";
6
+ import { tokens } from "../../../utils/design";
7
+ export function FormBody({ isFormSubmitting, submit, keyboardHeight, children, saveButtonLabel, renderStickySection, shouldRenderActionBar = true, secondaryActions, setSecondaryActionLoading, setSaveButtonHeight, saveButtonOffset, }) {
8
+ const paddingBottom = useBottomPadding();
9
+ const fullViewPadding = useMemo(() => ({ paddingBottom }), [paddingBottom]);
10
+ return (React.createElement(React.Fragment, null,
11
+ React.createElement(View, { style: [styles.container] },
12
+ children,
13
+ shouldRenderActionBar && (React.createElement(FormActionBar, { setSecondaryActionLoading: setSecondaryActionLoading, keyboardHeight: keyboardHeight, submit: submit, isFormSubmitting: isFormSubmitting, saveButtonLabel: saveButtonLabel, renderStickySection: renderStickySection, secondaryActions: secondaryActions, setSaveButtonHeight: setSaveButtonHeight }))),
14
+ shouldRenderActionBar && !saveButtonOffset && (React.createElement(View, { style: [fullViewPadding, styles.safeArea], testID: "ATL-FormSafeArea" }))));
15
+ }
16
+ export function useBottomPadding() {
17
+ const { insets } = useScreenInformation();
18
+ const extraBottomSpace = insets.bottom - tokens["space-base"];
19
+ return extraBottomSpace >= 0 ? extraBottomSpace : 0;
20
+ }
@@ -0,0 +1,26 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { tokens } from "../../../utils/design";
3
+ export const styles = StyleSheet.create({
4
+ container: {
5
+ flex: 1,
6
+ flexGrow: 1,
7
+ width: "100%",
8
+ },
9
+ safeArea: {
10
+ backgroundColor: tokens["color-surface"],
11
+ },
12
+ scrollContentContainer: {
13
+ flexGrow: 1,
14
+ },
15
+ scrollView: {
16
+ flexGrow: 1,
17
+ },
18
+ formChildContainer: {
19
+ flexGrow: 1,
20
+ justifyContent: "flex-start",
21
+ },
22
+ activityIndicator: {
23
+ marginVertical: tokens["space-base"],
24
+ flex: 1,
25
+ },
26
+ });
@@ -0,0 +1 @@
1
+ export { FormBody, useBottomPadding } from "./FormBody";