@terreno/ui 57.19.2 → 57.21.0

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 (379) hide show
  1. package/.ai/guidelines/core.md +1 -1
  2. package/CHANGELOG.md +443 -0
  3. package/dist/Accordion.d.ts.map +1 -1
  4. package/dist/Accordion.js +3 -3
  5. package/dist/Accordion.js.map +1 -1
  6. package/dist/Avatar.d.ts.map +1 -1
  7. package/dist/Avatar.js +3 -1
  8. package/dist/Avatar.js.map +1 -1
  9. package/dist/Box.d.ts.map +1 -1
  10. package/dist/Box.js +38 -2
  11. package/dist/Box.js.map +1 -1
  12. package/dist/Card.js +2 -2
  13. package/dist/Card.js.map +1 -1
  14. package/dist/Common.d.ts +175 -34
  15. package/dist/Common.d.ts.map +1 -1
  16. package/dist/Common.js.map +1 -1
  17. package/dist/ConsentFormScreen.d.ts +1 -1
  18. package/dist/ConsentFormScreen.d.ts.map +1 -1
  19. package/dist/ConsentFormScreen.js +13 -4
  20. package/dist/ConsentFormScreen.js.map +1 -1
  21. package/dist/DateTimeField.d.ts.map +1 -1
  22. package/dist/DateTimeField.js +11 -9
  23. package/dist/DateTimeField.js.map +1 -1
  24. package/dist/Field.d.ts.map +1 -1
  25. package/dist/Field.js +2 -0
  26. package/dist/Field.js.map +1 -1
  27. package/dist/FormContainer.d.ts +68 -0
  28. package/dist/FormContainer.d.ts.map +1 -0
  29. package/dist/FormContainer.js +79 -0
  30. package/dist/FormContainer.js.map +1 -0
  31. package/dist/GPTChat.d.ts.map +1 -1
  32. package/dist/GPTChat.js +2 -1
  33. package/dist/GPTChat.js.map +1 -1
  34. package/dist/Heading.d.ts +1 -1
  35. package/dist/Heading.d.ts.map +1 -1
  36. package/dist/Heading.js +5 -2
  37. package/dist/Heading.js.map +1 -1
  38. package/dist/HeightField.js +8 -8
  39. package/dist/HeightField.js.map +1 -1
  40. package/dist/Icon.d.ts +4 -0
  41. package/dist/Icon.d.ts.map +1 -1
  42. package/dist/Icon.js +43 -2
  43. package/dist/Icon.js.map +1 -1
  44. package/dist/LabeledCheckBox.d.ts +22 -0
  45. package/dist/LabeledCheckBox.d.ts.map +1 -0
  46. package/dist/LabeledCheckBox.js +30 -0
  47. package/dist/LabeledCheckBox.js.map +1 -0
  48. package/dist/ListDetailLayout.d.ts +36 -0
  49. package/dist/ListDetailLayout.d.ts.map +1 -0
  50. package/dist/ListDetailLayout.js +153 -0
  51. package/dist/ListDetailLayout.js.map +1 -0
  52. package/dist/MarkdownEditor.d.ts.map +1 -1
  53. package/dist/MarkdownEditor.js +2 -1
  54. package/dist/MarkdownEditor.js.map +1 -1
  55. package/dist/MediaQuery.d.ts +1 -1
  56. package/dist/MediaQuery.d.ts.map +1 -1
  57. package/dist/MediaQuery.js +1 -1
  58. package/dist/MediaQuery.js.map +1 -1
  59. package/dist/OtpField.d.ts +60 -0
  60. package/dist/OtpField.d.ts.map +1 -0
  61. package/dist/OtpField.js +154 -0
  62. package/dist/OtpField.js.map +1 -0
  63. package/dist/PickerSelect.js +9 -9
  64. package/dist/PickerSelect.js.map +1 -1
  65. package/dist/ProvisionalConsentSigner.d.ts +21 -0
  66. package/dist/ProvisionalConsentSigner.d.ts.map +1 -0
  67. package/dist/ProvisionalConsentSigner.js +199 -0
  68. package/dist/ProvisionalConsentSigner.js.map +1 -0
  69. package/dist/ResponsiveBreakpoint.d.ts +5 -0
  70. package/dist/ResponsiveBreakpoint.d.ts.map +1 -1
  71. package/dist/ResponsiveBreakpoint.js +7 -0
  72. package/dist/ResponsiveBreakpoint.js.map +1 -1
  73. package/dist/SocialLoginButton.d.ts +10 -0
  74. package/dist/SocialLoginButton.d.ts.map +1 -1
  75. package/dist/SocialLoginButton.js +26 -8
  76. package/dist/SocialLoginButton.js.map +1 -1
  77. package/dist/SplitPage.d.ts +11 -0
  78. package/dist/SplitPage.d.ts.map +1 -1
  79. package/dist/SplitPage.js +11 -5
  80. package/dist/SplitPage.js.map +1 -1
  81. package/dist/SplitPage.native.d.ts.map +1 -1
  82. package/dist/SplitPage.native.js +3 -1
  83. package/dist/SplitPage.native.js.map +1 -1
  84. package/dist/SyncStatusBanner.d.ts +7 -1
  85. package/dist/SyncStatusBanner.d.ts.map +1 -1
  86. package/dist/SyncStatusBanner.js +20 -4
  87. package/dist/SyncStatusBanner.js.map +1 -1
  88. package/dist/TapToEdit.d.ts +1 -1
  89. package/dist/TapToEdit.d.ts.map +1 -1
  90. package/dist/TapToEdit.js.map +1 -1
  91. package/dist/TextField.d.ts.map +1 -1
  92. package/dist/TextField.js +48 -14
  93. package/dist/TextField.js.map +1 -1
  94. package/dist/Theme.d.ts.map +1 -1
  95. package/dist/Theme.js +16 -0
  96. package/dist/Theme.js.map +1 -1
  97. package/dist/fieldElements/FieldError.d.ts.map +1 -1
  98. package/dist/fieldElements/FieldError.js +1 -1
  99. package/dist/fieldElements/FieldError.js.map +1 -1
  100. package/dist/index.d.ts +19 -3
  101. package/dist/index.d.ts.map +1 -1
  102. package/dist/index.js +14 -1
  103. package/dist/index.js.map +1 -1
  104. package/dist/lazyBoundaries/heavyOptionalExports.d.ts +3 -0
  105. package/dist/lazyBoundaries/heavyOptionalExports.d.ts.map +1 -1
  106. package/dist/lazyBoundaries/heavyOptionalExports.js +2 -0
  107. package/dist/lazyBoundaries/heavyOptionalExports.js.map +1 -1
  108. package/dist/login/LastUsedBadge.d.ts +14 -0
  109. package/dist/login/LastUsedBadge.d.ts.map +1 -0
  110. package/dist/login/LastUsedBadge.js +23 -0
  111. package/dist/login/LastUsedBadge.js.map +1 -0
  112. package/dist/login/LoginAccountCard.d.ts +38 -0
  113. package/dist/login/LoginAccountCard.d.ts.map +1 -0
  114. package/dist/login/LoginAccountCard.js +72 -0
  115. package/dist/login/LoginAccountCard.js.map +1 -0
  116. package/dist/login/LoginAccountList.d.ts +33 -0
  117. package/dist/login/LoginAccountList.d.ts.map +1 -0
  118. package/dist/login/LoginAccountList.js +30 -0
  119. package/dist/login/LoginAccountList.js.map +1 -0
  120. package/dist/login/LoginScreen.d.ts +4 -4
  121. package/dist/login/LoginScreen.d.ts.map +1 -1
  122. package/dist/login/LoginScreen.js +294 -13
  123. package/dist/login/LoginScreen.js.map +1 -1
  124. package/dist/login/OutlinePill.d.ts +28 -0
  125. package/dist/login/OutlinePill.d.ts.map +1 -0
  126. package/dist/login/OutlinePill.js +48 -0
  127. package/dist/login/OutlinePill.js.map +1 -0
  128. package/dist/login/TwoFactorChallengeScreen.d.ts +26 -0
  129. package/dist/login/TwoFactorChallengeScreen.d.ts.map +1 -0
  130. package/dist/login/TwoFactorChallengeScreen.js +139 -0
  131. package/dist/login/TwoFactorChallengeScreen.js.map +1 -0
  132. package/dist/login/loginMethods.d.ts +27 -0
  133. package/dist/login/loginMethods.d.ts.map +1 -0
  134. package/dist/login/loginMethods.js +37 -0
  135. package/dist/login/loginMethods.js.map +1 -0
  136. package/dist/login/loginTypes.d.ts +202 -5
  137. package/dist/login/loginTypes.d.ts.map +1 -1
  138. package/dist/pdfHtmlTemplate.d.ts +17 -0
  139. package/dist/pdfHtmlTemplate.d.ts.map +1 -1
  140. package/dist/pdfHtmlTemplate.js +78 -0
  141. package/dist/pdfHtmlTemplate.js.map +1 -1
  142. package/dist/security/AccountSecurityScreen.d.ts +10 -0
  143. package/dist/security/AccountSecurityScreen.d.ts.map +1 -0
  144. package/dist/security/AccountSecurityScreen.js +50 -0
  145. package/dist/security/AccountSecurityScreen.js.map +1 -0
  146. package/dist/security/LinkedAccountsCard.d.ts +32 -0
  147. package/dist/security/LinkedAccountsCard.d.ts.map +1 -0
  148. package/dist/security/LinkedAccountsCard.js +145 -0
  149. package/dist/security/LinkedAccountsCard.js.map +1 -0
  150. package/dist/security/PasskeysCard.d.ts +39 -0
  151. package/dist/security/PasskeysCard.d.ts.map +1 -0
  152. package/dist/security/PasskeysCard.js +168 -0
  153. package/dist/security/PasskeysCard.js.map +1 -0
  154. package/dist/security/PasswordCard.d.ts +32 -0
  155. package/dist/security/PasswordCard.d.ts.map +1 -0
  156. package/dist/security/PasswordCard.js +198 -0
  157. package/dist/security/PasswordCard.js.map +1 -0
  158. package/dist/security/SessionsCard.d.ts +39 -0
  159. package/dist/security/SessionsCard.d.ts.map +1 -0
  160. package/dist/security/SessionsCard.js +168 -0
  161. package/dist/security/SessionsCard.js.map +1 -0
  162. package/dist/security/TwoFactorSettingsCard.d.ts +55 -0
  163. package/dist/security/TwoFactorSettingsCard.d.ts.map +1 -0
  164. package/dist/security/TwoFactorSettingsCard.js +458 -0
  165. package/dist/security/TwoFactorSettingsCard.js.map +1 -0
  166. package/dist/security/securityMethods.d.ts +40 -0
  167. package/dist/security/securityMethods.d.ts.map +1 -0
  168. package/dist/security/securityMethods.js +66 -0
  169. package/dist/security/securityMethods.js.map +1 -0
  170. package/dist/security/securityTypes.d.ts +467 -0
  171. package/dist/security/securityTypes.d.ts.map +1 -0
  172. package/dist/security/securityTypes.js +2 -0
  173. package/dist/security/securityTypes.js.map +1 -0
  174. package/dist/security/userAgent.d.ts +26 -0
  175. package/dist/security/userAgent.d.ts.map +1 -0
  176. package/dist/security/userAgent.js +80 -0
  177. package/dist/security/userAgent.js.map +1 -0
  178. package/dist/signUp/OAuthButtons.d.ts +28 -5
  179. package/dist/signUp/OAuthButtons.d.ts.map +1 -1
  180. package/dist/signUp/OAuthButtons.js +44 -5
  181. package/dist/signUp/OAuthButtons.js.map +1 -1
  182. package/dist/signUp/SignUpScreen.d.ts.map +1 -1
  183. package/dist/signUp/SignUpScreen.js +50 -5
  184. package/dist/signUp/SignUpScreen.js.map +1 -1
  185. package/dist/signUp/signUpTypes.d.ts +21 -1
  186. package/dist/signUp/signUpTypes.d.ts.map +1 -1
  187. package/dist/useConsentForms.d.ts +9 -0
  188. package/dist/useConsentForms.d.ts.map +1 -1
  189. package/dist/useConsentForms.js +18 -0
  190. package/dist/useConsentForms.js.map +1 -1
  191. package/dist/useProvisionalConsent.d.ts +124 -0
  192. package/dist/useProvisionalConsent.d.ts.map +1 -0
  193. package/dist/useProvisionalConsent.js +79 -0
  194. package/dist/useProvisionalConsent.js.map +1 -0
  195. package/package.json +5 -2
  196. package/src/Accordion.test.tsx +5 -0
  197. package/src/Accordion.tsx +3 -8
  198. package/src/ActionSheet.test.tsx +13 -13
  199. package/src/AddressField.test.tsx +9 -3
  200. package/src/AnnouncementNavigator.test.tsx +4 -4
  201. package/src/AreaChart.test.tsx +15 -0
  202. package/src/Avatar.test.tsx +8 -0
  203. package/src/Avatar.tsx +2 -0
  204. package/src/Badge.test.tsx +1 -1
  205. package/src/Banner.test.tsx +0 -1
  206. package/src/BarChart.test.tsx +15 -0
  207. package/src/Box.test.tsx +143 -75
  208. package/src/Box.tsx +44 -2
  209. package/src/Button.test.tsx +11 -6
  210. package/src/Card.test.tsx +2 -2
  211. package/src/Card.tsx +2 -2
  212. package/src/Common.ts +194 -36
  213. package/src/ConflictSheet.test.tsx +5 -5
  214. package/src/ConsentFormScreen.test.tsx +87 -1
  215. package/src/ConsentFormScreen.tsx +28 -4
  216. package/src/ConsentNavigator.test.tsx +1 -2
  217. package/src/CustomSelectField.test.tsx +16 -4
  218. package/src/DataTable.test.tsx +4 -4
  219. package/src/DataTableVirtualizationRegression.test.tsx +1 -0
  220. package/src/DateTimeActionSheet.test.tsx +2 -0
  221. package/src/DateTimeField.test.tsx +3 -12
  222. package/src/DateTimeField.tsx +11 -9
  223. package/src/DismissButton.test.tsx +22 -4
  224. package/src/DonutChart.test.tsx +15 -0
  225. package/src/EmailField.test.tsx +13 -22
  226. package/src/EmojiSelector.test.tsx +2 -2
  227. package/src/ErrorBoundary.test.tsx +5 -3
  228. package/src/Field.test.tsx +20 -44
  229. package/src/Field.tsx +2 -0
  230. package/src/FilePickerButton.test.tsx +35 -0
  231. package/src/FormContainer.test.tsx +242 -0
  232. package/src/FormContainer.tsx +177 -0
  233. package/src/GPTChat.test.tsx +40 -16
  234. package/src/GPTChat.tsx +8 -2
  235. package/src/Heading.test.tsx +15 -1
  236. package/src/Heading.tsx +6 -1
  237. package/src/HeightField.tsx +8 -8
  238. package/src/Icon.test.tsx +54 -3
  239. package/src/Icon.tsx +92 -3
  240. package/src/IconButton.test.tsx +85 -0
  241. package/src/Image.test.tsx +1 -1
  242. package/src/LabeledCheckBox.test.tsx +45 -0
  243. package/src/LabeledCheckBox.tsx +89 -0
  244. package/src/Link.test.tsx +11 -4
  245. package/src/ListDetailLayout.tsx +247 -0
  246. package/src/MarkdownEditor.tsx +2 -1
  247. package/src/MarkdownView.test.tsx +1 -1
  248. package/src/MediaQuery.ts +1 -0
  249. package/src/MobileAddressAutoComplete.test.tsx +2 -1
  250. package/src/Modal.test.tsx +7 -2
  251. package/src/ModalSheet.test.tsx +5 -4
  252. package/src/MultiselectField.test.tsx +17 -3
  253. package/src/NumberField.test.tsx +14 -14
  254. package/src/NumberPickerActionSheet.test.tsx +1 -1
  255. package/src/OpenAPIContext.test.tsx +4 -4
  256. package/src/OpenAPIRenderRegression.test.tsx +1 -1
  257. package/src/OtpField.test.tsx +280 -0
  258. package/src/OtpField.tsx +307 -0
  259. package/src/P0RenderRegression.test.tsx +7 -1
  260. package/src/P1RenderRegression.test.tsx +1 -0
  261. package/src/P2ButtonRenderRegression.test.tsx +1 -0
  262. package/src/Page.test.tsx +1 -1
  263. package/src/PhoneNumberField.test.tsx +14 -38
  264. package/src/PickerSelect.tsx +9 -9
  265. package/src/Popover.test.tsx +2 -2
  266. package/src/ProvisionalConsentSigner.test.tsx +625 -0
  267. package/src/ProvisionalConsentSigner.tsx +423 -0
  268. package/src/RadioField.test.tsx +7 -2
  269. package/src/ResponsiveBreakpoint.test.tsx +7 -0
  270. package/src/ResponsiveBreakpoint.tsx +14 -0
  271. package/src/RootImportRegression.test.tsx +3 -0
  272. package/src/SegmentedControl.test.tsx +21 -12
  273. package/src/SidebarNavigation.test.tsx +18 -6
  274. package/src/Signature.test.tsx +20 -23
  275. package/src/Slider.test.tsx +1 -1
  276. package/src/SocialLoginButton.test.tsx +14 -0
  277. package/src/SocialLoginButton.tsx +51 -7
  278. package/src/SplitPage.native.tsx +3 -1
  279. package/src/SplitPage.test.tsx +15 -5
  280. package/src/SplitPage.tsx +11 -5
  281. package/src/SyncStatusBanner.test.tsx +61 -4
  282. package/src/SyncStatusBanner.tsx +29 -3
  283. package/src/TapToEdit.test.tsx +38 -15
  284. package/src/TapToEdit.tsx +1 -1
  285. package/src/TerrenoFontProvider.test.tsx +1 -1
  286. package/src/Text.test.tsx +4 -4
  287. package/src/TextField.test.tsx +232 -9
  288. package/src/TextField.tsx +70 -12
  289. package/src/Theme.test.tsx +49 -0
  290. package/src/Theme.tsx +16 -0
  291. package/src/Toast.test.tsx +5 -5
  292. package/src/ToastNotifications.test.tsx +73 -70
  293. package/src/ToastNotifications.webModal.test.tsx +2 -2
  294. package/src/Tooltip.test.tsx +3 -3
  295. package/src/UnifiedAddressAutoComplete.test.tsx +1 -1
  296. package/src/UserInactivity.test.tsx +4 -2
  297. package/src/WebAddressAutocomplete.test.tsx +12 -12
  298. package/src/WebDropdownMenu.test.tsx +16 -15
  299. package/src/__snapshots__/AddressField.test.tsx.snap +12 -0
  300. package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +15 -0
  301. package/src/__snapshots__/Avatar.test.tsx.snap +1 -0
  302. package/src/__snapshots__/Card.test.tsx.snap +1 -1
  303. package/src/__snapshots__/CustomSelectField.test.tsx.snap +3 -0
  304. package/src/__snapshots__/DismissButton.test.tsx.snap +3 -3
  305. package/src/__snapshots__/EmailField.test.tsx.snap +6 -0
  306. package/src/__snapshots__/Field.test.tsx.snap +41 -2
  307. package/src/__snapshots__/Heading.test.tsx.snap +1 -1
  308. package/src/__snapshots__/HeightField.test.tsx.snap +2 -0
  309. package/src/__snapshots__/Image.test.tsx.snap +1 -1
  310. package/src/__snapshots__/MobileAddressAutoComplete.test.tsx.snap +3 -0
  311. package/src/__snapshots__/NumberField.test.tsx.snap +3 -0
  312. package/src/__snapshots__/Page.test.tsx.snap +2 -2
  313. package/src/__snapshots__/PhoneNumberField.test.tsx.snap +12 -0
  314. package/src/__snapshots__/Slider.test.tsx.snap +1 -0
  315. package/src/__snapshots__/SocialLoginButton.test.tsx.snap +43 -22
  316. package/src/__snapshots__/TapToEdit.test.tsx.snap +3 -0
  317. package/src/__snapshots__/Text.test.tsx.snap +1 -1
  318. package/src/__snapshots__/TextArea.test.tsx.snap +17 -1
  319. package/src/__snapshots__/TextField.test.tsx.snap +19 -2
  320. package/src/__snapshots__/TypedSignatureField.test.tsx.snap +3 -0
  321. package/src/__snapshots__/UnifiedAddressAutoComplete.test.tsx.snap +18 -0
  322. package/src/__snapshots__/WebAddressAutocomplete.test.tsx.snap +12 -0
  323. package/src/asks/AskCard.test.tsx +16 -13
  324. package/src/asks/AskFiles.test.tsx +5 -1
  325. package/src/asks/askFileRefs.test.ts +1 -1
  326. package/src/asks/askSummary.test.ts +2 -2
  327. package/src/benchmarks/importTiming.ts +1 -1
  328. package/src/blocks/BlocksView.test.tsx +20 -11
  329. package/src/bunSetup.ts +14 -2
  330. package/src/dataTableFilters.test.tsx +1 -1
  331. package/src/fieldElements/FieldError.tsx +1 -0
  332. package/src/fieldElements/__snapshots__/FieldError.test.tsx.snap +2 -0
  333. package/src/index.tsx +42 -1
  334. package/src/isolated/ListDetailLayout.isolated.tsx +632 -0
  335. package/src/lazyBoundaries/heavyOptionalExports.tsx +7 -0
  336. package/src/login/LastUsedBadge.tsx +40 -0
  337. package/src/login/LoginAccountCard.tsx +205 -0
  338. package/src/login/LoginAccountList.tsx +115 -0
  339. package/src/login/LoginScreen.test.tsx +839 -3
  340. package/src/login/LoginScreen.tsx +674 -91
  341. package/src/login/OutlinePill.tsx +110 -0
  342. package/src/login/TwoFactorChallengeScreen.test.tsx +376 -0
  343. package/src/login/TwoFactorChallengeScreen.tsx +307 -0
  344. package/src/login/__snapshots__/LoginScreen.test.tsx.snap +1454 -334
  345. package/src/login/loginMethods.test.ts +53 -0
  346. package/src/login/loginMethods.ts +60 -0
  347. package/src/login/loginTypes.ts +208 -5
  348. package/src/pdfHtmlTemplate.test.ts +243 -4
  349. package/src/pdfHtmlTemplate.ts +93 -0
  350. package/src/security/AccountSecurityScreen.test.tsx +262 -0
  351. package/src/security/AccountSecurityScreen.tsx +156 -0
  352. package/src/security/LinkedAccountsCard.test.tsx +371 -0
  353. package/src/security/LinkedAccountsCard.tsx +297 -0
  354. package/src/security/PasskeysCard.test.tsx +378 -0
  355. package/src/security/PasskeysCard.tsx +371 -0
  356. package/src/security/PasswordCard.test.tsx +445 -0
  357. package/src/security/PasswordCard.tsx +342 -0
  358. package/src/security/SessionsCard.test.tsx +349 -0
  359. package/src/security/SessionsCard.tsx +362 -0
  360. package/src/security/TwoFactorSettingsCard.test.tsx +700 -0
  361. package/src/security/TwoFactorSettingsCard.tsx +872 -0
  362. package/src/security/securityMethods.test.ts +101 -0
  363. package/src/security/securityMethods.ts +104 -0
  364. package/src/security/securityTypes.ts +480 -0
  365. package/src/security/userAgent.test.ts +119 -0
  366. package/src/security/userAgent.ts +102 -0
  367. package/src/signUp/OAuthButtons.test.tsx +27 -0
  368. package/src/signUp/OAuthButtons.tsx +153 -19
  369. package/src/signUp/SignUpScreen.test.tsx +171 -2
  370. package/src/signUp/SignUpScreen.tsx +87 -25
  371. package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +22 -11
  372. package/src/signUp/signUpTypes.ts +23 -1
  373. package/src/table/tableContext.test.tsx +5 -5
  374. package/src/test-utils.tsx +56 -1
  375. package/src/testing/reactDomServer.d.ts +7 -0
  376. package/src/useConsentForms.test.ts +38 -2
  377. package/src/useConsentForms.ts +25 -0
  378. package/src/useProvisionalConsent.test.ts +256 -0
  379. package/src/useProvisionalConsent.ts +218 -0
@@ -1,18 +1,190 @@
1
- import type {FC} from "react";
2
- import {useCallback, useState} from "react";
1
+ import type {FC, ReactElement, ReactNode} from "react";
2
+ import {useCallback, useEffect, useRef, useState} from "react";
3
+ import {Platform, Pressable, type TextInput, View} from "react-native";
3
4
 
5
+ import {Avatar} from "../Avatar";
4
6
  import {Box} from "../Box";
5
7
  import {Button} from "../Button";
8
+ import type {IconName, TextFieldProps} from "../Common";
9
+ import {FormContainer, type FormContainerHandle} from "../FormContainer";
6
10
  import {Heading} from "../Heading";
11
+ import {Icon} from "../Icon";
7
12
  import {Page} from "../Page";
8
13
  import {OAuthButtons} from "../signUp/OAuthButtons";
9
14
  import {Text} from "../Text";
10
15
  import {TextField} from "../TextField";
11
- import type {LoginScreenProps} from "./loginTypes";
16
+ import {useTheme} from "../Theme";
17
+ import {LastUsedPill} from "./LastUsedBadge";
18
+ import {LoginAccountList} from "./LoginAccountList";
19
+ import {getLoginMethodLabels, withLastUsedLabel} from "./loginMethods";
20
+ import type {
21
+ LoginAccountOption,
22
+ LoginFieldConfig,
23
+ LoginNotice,
24
+ LoginScreenProps,
25
+ } from "./loginTypes";
26
+ import {OutlinePill} from "./OutlinePill";
27
+
28
+ const DEFAULT_LAST_USED_LABEL = "Last used";
29
+ const DEFAULT_SIGN_UP_LINK = "Create an account";
30
+ const DEFAULT_FORGOT_PASSWORD = "Forgot password?";
31
+
32
+ const isEmailField = (field: LoginFieldConfig): boolean => {
33
+ return field.type === "email" || field.name === "email";
34
+ };
35
+
36
+ const isPasswordField = (field: LoginFieldConfig): boolean => {
37
+ return field.type === "password" || field.name === "password";
38
+ };
12
39
 
13
40
  /**
14
- * A configurable login screen component with support for custom fields,
15
- * OAuth providers, sign-up link, and forgot password link.
41
+ * The autofill hint for a field: passkey autofill on a web email field, else the field's own hint,
42
+ * else "username" for the email field and "current-password" for password fields, so password
43
+ * managers pair the two.
44
+ */
45
+ const getFieldAutoComplete = ({
46
+ field,
47
+ passkeyAutofill,
48
+ }: {
49
+ field: LoginFieldConfig;
50
+ passkeyAutofill: boolean;
51
+ }): TextFieldProps["autoComplete"] => {
52
+ if (passkeyAutofill && Platform.OS === "web" && isEmailField(field)) {
53
+ return "username webauthn";
54
+ }
55
+ if (field.autoComplete) {
56
+ return field.autoComplete;
57
+ }
58
+ if (isEmailField(field)) {
59
+ return "username";
60
+ }
61
+ return field.type === "password" ? "current-password" : undefined;
62
+ };
63
+
64
+ /** A labelled rule between two groups of sign-in methods. */
65
+ const MethodDivider: FC<{text: string}> = ({text}) => {
66
+ const {theme} = useTheme();
67
+ if (!theme) {
68
+ return null;
69
+ }
70
+ return (
71
+ <View style={{alignItems: "center", flexDirection: "row", gap: 12, width: "100%"}}>
72
+ <View style={{backgroundColor: theme.border.default, flex: 1, height: 1}} />
73
+ <Text color="secondaryLight" size="sm">
74
+ {text}
75
+ </Text>
76
+ <View style={{backgroundColor: theme.border.default, flex: 1, height: 1}} />
77
+ </View>
78
+ );
79
+ };
80
+
81
+ const TextLink: FC<{
82
+ text: string;
83
+ onPress: () => void;
84
+ testID: string;
85
+ disabled?: boolean;
86
+ color?: "link" | "secondaryLight";
87
+ }> = ({text, onPress, testID, disabled = false, color = "link"}) => {
88
+ return (
89
+ <Pressable
90
+ accessibilityRole="link"
91
+ accessibilityState={{disabled}}
92
+ disabled={disabled}
93
+ onPress={onPress}
94
+ testID={testID}
95
+ >
96
+ <Text bold color={color} size="sm">
97
+ {text}
98
+ </Text>
99
+ </Pressable>
100
+ );
101
+ };
102
+
103
+ const NoticeBox: FC<{
104
+ notice: LoginNotice;
105
+ onAction: () => void;
106
+ onDismiss?: () => void;
107
+ testID: string;
108
+ }> = ({notice, onAction, onDismiss, testID}) => {
109
+ const {theme} = useTheme();
110
+ if (!theme) {
111
+ return null;
112
+ }
113
+ const tone = notice.tone;
114
+ const isInfo = tone === "info";
115
+ const fill =
116
+ tone === "error"
117
+ ? theme.surface.errorLight
118
+ : tone === "warning"
119
+ ? theme.surface.warningLight
120
+ : theme.surface.secondaryExtraLight;
121
+ const border =
122
+ tone === "error"
123
+ ? theme.border.error
124
+ : tone === "warning"
125
+ ? theme.border.warning
126
+ : theme.surface.secondaryLight;
127
+ const iconName: IconName =
128
+ tone === "error"
129
+ ? "circle-exclamation"
130
+ : tone === "warning"
131
+ ? "triangle-exclamation"
132
+ : "circle-info";
133
+ const iconColor = tone === "error" ? "error" : tone === "warning" ? "warning" : "secondaryDark";
134
+ const textColor = isInfo ? "secondaryDark" : "primary";
135
+ return (
136
+ <View role={isInfo ? "status" : "alert"} style={{width: "100%"}} testID={testID}>
137
+ <View
138
+ style={{
139
+ backgroundColor: fill,
140
+ borderColor: border,
141
+ borderRadius: theme.radius.full,
142
+ borderWidth: 1,
143
+ gap: 12,
144
+ paddingHorizontal: 16,
145
+ paddingVertical: 12,
146
+ width: "100%",
147
+ }}
148
+ >
149
+ <Box alignItems="start" direction="row" gap={3}>
150
+ <Icon color={iconColor} iconName={iconName} size="lg" />
151
+ <Box flex="shrink" gap={1}>
152
+ {Boolean(notice.title) && (
153
+ <Text bold color={textColor}>
154
+ {notice.title}
155
+ </Text>
156
+ )}
157
+ <Text color={textColor}>{notice.text}</Text>
158
+ </Box>
159
+ {isInfo && Boolean(onDismiss) && (
160
+ <Pressable
161
+ accessibilityLabel="Dismiss"
162
+ accessibilityRole="button"
163
+ onPress={onDismiss}
164
+ testID={`${testID}-dismiss`}
165
+ >
166
+ <Icon color="secondaryDark" iconName="xmark" size="md" />
167
+ </Pressable>
168
+ )}
169
+ </Box>
170
+ {Boolean(notice.actionLabel) && (
171
+ <Box alignItems="start">
172
+ <Button
173
+ onClick={onAction}
174
+ testID={`${testID}-action`}
175
+ text={notice.actionLabel!}
176
+ variant="outline"
177
+ />
178
+ </Box>
179
+ )}
180
+ </View>
181
+ </View>
182
+ );
183
+ };
184
+
185
+ /**
186
+ * A configurable login screen. It is presentational: it renders the methods and accounts it is
187
+ * given and reports presses through callbacks.
16
188
  *
17
189
  * @example
18
190
  * ```tsx
@@ -27,9 +199,9 @@ import type {LoginScreenProps} from "./loginTypes";
27
199
  * oauthProviders={[
28
200
  * {provider: "google", onPress: () => signInWithSocial("google")},
29
201
  * ]}
202
+ * lastUsedMethod="google"
203
+ * onPasskeyPress={signInWithPasskey}
30
204
  * onSignUpPress={() => router.push("/signup")}
31
- * onForgotPasswordPress={() => router.push("/forgot-password")}
32
- // or onForgotPassword={() => router.push("/forgot-password")}
33
205
  * />
34
206
  * ```
35
207
  */
@@ -37,24 +209,65 @@ export const LoginScreen: FC<LoginScreenProps> = ({
37
209
  fields,
38
210
  onSubmit,
39
211
  oauthProviders,
212
+ genericProviders,
40
213
  logo,
41
- title = "Welcome Back",
214
+ title,
215
+ subtitle,
42
216
  loading = false,
43
217
  error,
44
- signUpLinkText = "Need an account? Sign Up",
218
+ passwordError,
219
+ signUpLinkText = DEFAULT_SIGN_UP_LINK,
45
220
  onSignUpPress,
46
- forgotPasswordText = "Forgot password?",
221
+ forgotPasswordText = DEFAULT_FORGOT_PASSWORD,
47
222
  onForgotPasswordPress,
48
223
  onForgotPassword,
224
+ lastUsedMethod,
225
+ lastUsedLabel = DEFAULT_LAST_USED_LABEL,
226
+ currentSessions,
227
+ rememberedAccounts,
228
+ onContinue,
229
+ onForget,
230
+ continuingAccount,
231
+ onCancelContinue,
232
+ initialMethodsExpanded = false,
233
+ initialAccountsEditing = false,
234
+ onPasskeyPress,
235
+ passkeyButtonText = "Sign in with a passkey",
236
+ passkeyAutofill = false,
237
+ notice,
238
+ initialValues,
49
239
  testID = "login-screen",
50
240
  }) => {
51
241
  const [formValues, setFormValues] = useState<Record<string, string>>(() => {
52
242
  const initial: Record<string, string> = {};
53
243
  for (const field of fields) {
54
- initial[field.name] = "";
244
+ initial[field.name] = initialValues?.[field.name] ?? "";
55
245
  }
56
246
  return initial;
57
247
  });
248
+ const [methodsExpanded, setMethodsExpanded] = useState(initialMethodsExpanded);
249
+ const [dismissedNotice, setDismissedNotice] = useState<string | undefined>();
250
+ const [pendingFocus, setPendingFocus] = useState<string | undefined>();
251
+
252
+ // Applies a new initialValues object over the form; the first render already used it.
253
+ const appliedInitialValues = useRef(initialValues);
254
+ useEffect(() => {
255
+ if (!initialValues || appliedInitialValues.current === initialValues) {
256
+ return;
257
+ }
258
+ appliedInitialValues.current = initialValues;
259
+ setFormValues((prev) => ({...prev, ...initialValues}));
260
+ }, [initialValues]);
261
+
262
+ const noticeText = notice?.text;
263
+ // A replaced notice is shown again. Dismiss only hides the notice currently on screen.
264
+ useEffect(() => {
265
+ if (noticeText === undefined) {
266
+ setDismissedNotice(undefined);
267
+ return;
268
+ }
269
+ setDismissedNotice(undefined);
270
+ }, [noticeText]);
58
271
 
59
272
  const onForgotPasswordAction = onForgotPasswordPress ?? onForgotPassword;
60
273
 
@@ -62,103 +275,473 @@ export const LoginScreen: FC<LoginScreenProps> = ({
62
275
  setFormValues((prev) => ({...prev, [fieldName]: value}));
63
276
  }, []);
64
277
 
65
- const handleSubmit = useCallback(async () => {
66
- await onSubmit(formValues);
67
- }, [formValues, onSubmit]);
278
+ const formRef = useRef<FormContainerHandle>(null);
279
+ const inputRefs = useRef<Record<string, TextInput | null>>({});
280
+ const isSubmittingRef = useRef(false);
281
+
282
+ const handlePasskeyPress = useCallback(async (): Promise<void> => {
283
+ await onPasskeyPress?.();
284
+ }, [onPasskeyPress]);
68
285
 
286
+ const passwordField = fields.find((field) => isPasswordField(field));
69
287
  const requiredFieldsFilled = fields
70
- .filter((f) => f.required)
71
- .every((f) => (formValues[f.name] ?? "").trim().length > 0);
288
+ .filter((field) => field.required)
289
+ .every((field) => {
290
+ if (continuingAccount?.email && isEmailField(field)) {
291
+ return true;
292
+ }
293
+ return (formValues[field.name] ?? "").trim().length > 0;
294
+ });
72
295
 
73
296
  const isSubmitDisabled = loading || !requiredFieldsFilled;
74
297
 
75
- return (
76
- <Page navigation={undefined}>
77
- <Box
78
- alignItems="center"
79
- alignSelf="center"
80
- flex="grow"
81
- justifyContent="center"
82
- maxWidth={400}
83
- padding={4}
84
- testID={testID}
85
- width="100%"
86
- >
87
- {Boolean(logo) && <Box marginBottom={6}>{logo}</Box>}
298
+ const handleSubmit = useCallback(async (): Promise<void> => {
299
+ if (isSubmitDisabled || isSubmittingRef.current) {
300
+ return;
301
+ }
302
+ isSubmittingRef.current = true;
303
+ try {
304
+ const values = {...formValues};
305
+ if (continuingAccount?.email) {
306
+ values.email = continuingAccount.email;
307
+ }
308
+ await onSubmit(values);
309
+ } finally {
310
+ isSubmittingRef.current = false;
311
+ }
312
+ }, [continuingAccount?.email, formValues, isSubmitDisabled, onSubmit]);
88
313
 
89
- <Box marginBottom={8}>
90
- <Heading testID={`${testID}-title`}>{title}</Heading>
91
- </Box>
314
+ const requestSubmit = useCallback(async (): Promise<void> => {
315
+ if (isSubmitDisabled) {
316
+ return;
317
+ }
318
+ await formRef.current?.requestSubmit();
319
+ }, [isSubmitDisabled]);
92
320
 
93
- <Box gap={4} width="100%">
94
- {fields.map((field) => (
95
- <TextField
96
- autoComplete={field.autoComplete}
97
- disabled={loading}
98
- id={`${testID}-${field.name}-input`}
99
- key={field.name}
100
- onChange={(value: string) => handleFieldChange(field.name, value)}
101
- placeholder={field.placeholder ?? field.label}
102
- testID={`${testID}-${field.name}-input`}
103
- title={field.label}
104
- type={
105
- field.type === "email" ? "email" : field.type === "password" ? "password" : "text"
106
- }
107
- value={formValues[field.name]}
108
- />
109
- ))}
321
+ const focusField = useCallback((fieldName: string): void => {
322
+ inputRefs.current[fieldName]?.focus();
323
+ }, []);
110
324
 
111
- {Boolean(error) && (
112
- <Text color="error" testID={`${testID}-error`}>
113
- {error}
114
- </Text>
115
- )}
325
+ // The password step opens with the password field focused so the user can type at once.
326
+ useEffect(() => {
327
+ if (!continuingAccount) {
328
+ return;
329
+ }
330
+ focusField("password");
331
+ }, [continuingAccount, focusField]);
116
332
 
117
- <Box marginTop={4}>
118
- <Button
119
- disabled={isSubmitDisabled}
120
- fullWidth
121
- loading={loading}
122
- onClick={handleSubmit}
123
- testID={`${testID}-submit-button`}
124
- text="Log In"
125
- />
126
- </Box>
333
+ // An account-not-linked action expands the methods, then focuses email once the field is mounted.
334
+ useEffect(() => {
335
+ if (pendingFocus !== "email") {
336
+ return;
337
+ }
338
+ const emailInput = inputRefs.current.email;
339
+ if (!emailInput) {
340
+ return;
341
+ }
342
+ emailInput.focus();
343
+ setPendingFocus(undefined);
344
+ }, [pendingFocus]);
127
345
 
128
- {Boolean(onForgotPasswordAction) && (
129
- <Box alignItems="center" marginTop={2}>
130
- <Button
131
- disabled={loading}
132
- onClick={onForgotPasswordAction!}
133
- testID={`${testID}-forgot-password`}
134
- text={forgotPasswordText!}
135
- variant="muted"
136
- />
137
- </Box>
138
- )}
346
+ const brandedProviders = oauthProviders ?? [];
347
+ const otherProviders = genericProviders ?? [];
348
+ const hasProviders = brandedProviders.length > 0 || otherProviders.length > 0;
349
+ const hasPasskey = Boolean(onPasskeyPress);
350
+ const hasMethods = hasProviders || hasPasskey;
351
+ const hasForm = fields.length > 0;
352
+ const isProviderLastUsed =
353
+ Boolean(lastUsedMethod) &&
354
+ (brandedProviders.some((config) => config.provider === lastUsedMethod) ||
355
+ otherProviders.some((config) => config.id === lastUsedMethod));
356
+ const isPasskeyLastUsed = lastUsedMethod === "passkey" && hasPasskey;
357
+ const isEmailLastUsed = lastUsedMethod === "email";
139
358
 
140
- {Boolean(onSignUpPress) && (
141
- <Box marginTop={2}>
142
- <Button
143
- disabled={loading}
144
- fullWidth
145
- onClick={onSignUpPress!}
146
- testID={`${testID}-signup-link`}
147
- text={signUpLinkText!}
148
- variant="outline"
149
- />
150
- </Box>
151
- )}
359
+ const accountEntries =
360
+ onContinue === undefined
361
+ ? []
362
+ : [
363
+ ...(currentSessions ?? []).map((account) => ({
364
+ account,
365
+ method: getLoginMethodLabels({
366
+ genericProviders: otherProviders,
367
+ method: account.method,
368
+ }),
369
+ source: "session" as const,
370
+ })),
371
+ ...(rememberedAccounts ?? []).map((account) => ({
372
+ account,
373
+ method: getLoginMethodLabels({
374
+ genericProviders: otherProviders,
375
+ method: account.method,
376
+ }),
377
+ source: "remembered" as const,
378
+ })),
379
+ ];
380
+ const hasAccounts = accountEntries.length > 0;
381
+ const showMethods = !hasAccounts || methodsExpanded;
382
+ const resolvedTitle = title ?? (hasAccounts ? "Welcome back" : "Sign in");
383
+ const resolvedSubtitle =
384
+ subtitle ?? (hasAccounts ? "Pick up where you left off." : "Choose how you want to sign in.");
385
+
386
+ const visibleNotice =
387
+ notice && dismissedNotice !== `${notice.tone}:${notice.title ?? ""}:${notice.text}`
388
+ ? notice
389
+ : undefined;
390
+ const banner: LoginNotice | undefined = visibleNotice
391
+ ? visibleNotice
392
+ : error
393
+ ? {text: error, tone: "error"}
394
+ : undefined;
395
+
396
+ const handleNoticeAction = useCallback((): void => {
397
+ if (notice?.focusMethod) {
398
+ setMethodsExpanded(true);
399
+ setPendingFocus(notice.focusMethod);
400
+ }
401
+ void notice?.onAction?.();
402
+ }, [notice]);
152
403
 
153
- {Boolean(oauthProviders && oauthProviders.length > 0) && (
154
- <OAuthButtons
404
+ const handleDismissNotice = useCallback((): void => {
405
+ if (!notice) {
406
+ return;
407
+ }
408
+ setDismissedNotice(`${notice.tone}:${notice.title ?? ""}:${notice.text}`);
409
+ }, [notice]);
410
+
411
+ const expandMethods = useCallback((): void => {
412
+ setMethodsExpanded(true);
413
+ }, []);
414
+
415
+ const handleCancelContinue = useCallback((): void => {
416
+ onCancelContinue?.();
417
+ }, [onCancelContinue]);
418
+
419
+ const renderPasskey = (): ReactElement => (
420
+ <OutlinePill
421
+ accessibilityLabel={
422
+ isPasskeyLastUsed
423
+ ? withLastUsedLabel({label: passkeyButtonText, lastUsedLabel})
424
+ : passkeyButtonText
425
+ }
426
+ disabled={loading}
427
+ icon={<Icon color={loading ? "secondaryLight" : "primary"} iconName="key" size="md" />}
428
+ lastUsedLabel={isPasskeyLastUsed ? lastUsedLabel : undefined}
429
+ lastUsedTestID={`${testID}-last-used-passkey`}
430
+ onPress={handlePasskeyPress}
431
+ testID={`${testID}-passkey-button`}
432
+ text={passkeyButtonText}
433
+ />
434
+ );
435
+
436
+ const renderMethodStack = (): ReactElement => (
437
+ <Box gap={3} width="100%">
438
+ {isPasskeyLastUsed && renderPasskey()}
439
+ {hasProviders && (
440
+ <OAuthButtons
441
+ appearance="pill"
442
+ disabled={loading}
443
+ dividerPosition="none"
444
+ genericProviders={otherProviders}
445
+ lastUsed={
446
+ isProviderLastUsed
447
+ ? {
448
+ label: lastUsedLabel,
449
+ provider: lastUsedMethod!,
450
+ testID: `${testID}-last-used-${lastUsedMethod}`,
451
+ }
452
+ : undefined
453
+ }
454
+ providers={brandedProviders}
455
+ testID={`${testID}-oauth`}
456
+ />
457
+ )}
458
+ {hasPasskey && !isPasskeyLastUsed && renderPasskey()}
459
+ </Box>
460
+ );
461
+
462
+ const renderField = (
463
+ field: LoginFieldConfig,
464
+ index: number,
465
+ visibleFields: LoginFieldConfig[]
466
+ ): ReactElement => {
467
+ const nextField = visibleFields[index + 1];
468
+ const emailLastUsed = isEmailLastUsed && isEmailField(field);
469
+ const showForgot = isPasswordField(field) && Boolean(onForgotPasswordAction);
470
+ const fieldError = isPasswordField(field) ? passwordError : undefined;
471
+ const placeholder = isPasswordField(field)
472
+ ? undefined
473
+ : isEmailField(field)
474
+ ? (field.placeholder ?? "you@example.com")
475
+ : (field.placeholder ?? field.label);
476
+ return (
477
+ <Box gap={2} key={field.name} width="100%">
478
+ <Box alignItems="center" direction="row" justifyContent="between" width="100%">
479
+ <Box alignItems="center" direction="row" gap={2}>
480
+ <Text bold>{field.label}</Text>
481
+ {emailLastUsed && (
482
+ <LastUsedPill label={lastUsedLabel} testID={`${testID}-last-used-email`} />
483
+ )}
484
+ </Box>
485
+ {showForgot && (
486
+ <TextLink
155
487
  disabled={loading}
156
- providers={oauthProviders!}
157
- testID={`${testID}-oauth`}
488
+ onPress={onForgotPasswordAction!}
489
+ testID={`${testID}-forgot-password`}
490
+ text={forgotPasswordText}
158
491
  />
159
492
  )}
160
493
  </Box>
494
+ <TextField
495
+ accessibilityLabel={
496
+ emailLastUsed ? withLastUsedLabel({label: field.label, lastUsedLabel}) : field.label
497
+ }
498
+ autoComplete={getFieldAutoComplete({field, passkeyAutofill})}
499
+ blurOnSubmit={!nextField}
500
+ disabled={loading}
501
+ errorPosition="below"
502
+ errorText={fieldError}
503
+ id={`${testID}-${field.name}-input`}
504
+ inputRef={(ref) => {
505
+ inputRefs.current[field.name] = ref;
506
+ }}
507
+ onChange={(value: string) => handleFieldChange(field.name, value)}
508
+ onEnter={nextField ? () => focusField(nextField.name) : requestSubmit}
509
+ placeholder={placeholder}
510
+ returnKeyType={nextField ? "next" : "go"}
511
+ testID={`${testID}-${field.name}-input`}
512
+ type={field.type === "email" ? "email" : field.type === "password" ? "password" : "text"}
513
+ value={formValues[field.name]}
514
+ />
515
+ </Box>
516
+ );
517
+ };
518
+
519
+ const renderFooter = (): ReactNode => {
520
+ if (!onSignUpPress) {
521
+ return null;
522
+ }
523
+ return (
524
+ <Box alignItems="center" direction="row" gap={1} justifyContent="center" paddingY={2}>
525
+ <Text color="secondaryLight">New here?</Text>
526
+ <Pressable
527
+ accessibilityRole="link"
528
+ disabled={loading}
529
+ onPress={onSignUpPress}
530
+ testID={`${testID}-signup-link`}
531
+ >
532
+ <Text bold color="link">
533
+ {signUpLinkText}
534
+ </Text>
535
+ </Pressable>
536
+ </Box>
537
+ );
538
+ };
539
+
540
+ const renderContinueStep = (): ReactElement => {
541
+ const account = continuingAccount!;
542
+ const who = account.name ?? account.email ?? "this account";
543
+ return (
544
+ <Box gap={6} width="100%">
545
+ <Pressable
546
+ accessibilityRole="link"
547
+ disabled={loading}
548
+ onPress={handleCancelContinue}
549
+ testID={`${testID}-continue-back`}
550
+ >
551
+ <Box alignItems="center" direction="row" gap={1}>
552
+ <Icon color="link" iconName="chevron-left" size="md" />
553
+ <Text bold color="link">
554
+ All sign-in options
555
+ </Text>
556
+ </Box>
557
+ </Pressable>
558
+ <Heading size="xl">Enter your password</Heading>
559
+ <IdentityChip
560
+ account={account}
561
+ disabled={loading}
562
+ onNotYou={handleCancelContinue}
563
+ testID={`${testID}-continue-not-you`}
564
+ who={who}
565
+ />
566
+ <FormContainer
567
+ accessibilityLabel="Enter your password"
568
+ gap={4}
569
+ onSubmit={handleSubmit}
570
+ ref={formRef}
571
+ testID={`${testID}-form`}
572
+ width="100%"
573
+ >
574
+ <View
575
+ accessibilityElementsHidden
576
+ importantForAccessibility="no-hide-descendants"
577
+ style={{height: 0, overflow: "hidden", width: "100%"}}
578
+ >
579
+ <TextField
580
+ accessibilityLabel="Email"
581
+ autoComplete="username"
582
+ onChange={() => {}}
583
+ testID={`${testID}-email-input`}
584
+ type="email"
585
+ value={account.email ?? ""}
586
+ />
587
+ </View>
588
+ {passwordField && renderField(passwordField, 0, [passwordField])}
589
+ <Button
590
+ disabled={isSubmitDisabled}
591
+ fullWidth
592
+ loading={loading}
593
+ onClick={requestSubmit}
594
+ testID={`${testID}-submit-button`}
595
+ text={loading ? "Signing in" : "Sign in"}
596
+ />
597
+ </FormContainer>
161
598
  </Box>
599
+ );
600
+ };
601
+
602
+ const visibleFields = continuingAccount ? [] : fields;
603
+
604
+ return (
605
+ <Page navigation={undefined}>
606
+ <View
607
+ accessibilityState={{busy: loading}}
608
+ aria-busy={loading}
609
+ style={{alignItems: "center", flexGrow: 1, width: "100%"}}
610
+ >
611
+ <Box alignSelf="center" flex="grow" maxWidth={400} padding={4} testID={testID} width="100%">
612
+ <Box flex="grow" gap={5} width="100%">
613
+ {Boolean(logo) && <Box>{logo}</Box>}
614
+ {!continuingAccount && (
615
+ <Box gap={1}>
616
+ <Heading size="xl" testID={`${testID}-title`}>
617
+ {resolvedTitle}
618
+ </Heading>
619
+ <Text color="secondaryLight" testID={`${testID}-subtitle`}>
620
+ {resolvedSubtitle}
621
+ </Text>
622
+ </Box>
623
+ )}
624
+ {Boolean(banner) && (
625
+ <NoticeBox
626
+ notice={banner!}
627
+ onAction={handleNoticeAction}
628
+ onDismiss={banner?.tone === "info" ? handleDismissNotice : undefined}
629
+ testID={
630
+ banner?.tone === "error" && !visibleNotice
631
+ ? `${testID}-error`
632
+ : `${testID}-notice`
633
+ }
634
+ />
635
+ )}
636
+ {continuingAccount ? (
637
+ renderContinueStep()
638
+ ) : (
639
+ <Box gap={5} width="100%">
640
+ {hasAccounts && (
641
+ <LoginAccountList
642
+ accounts={accountEntries}
643
+ disabled={loading}
644
+ initialEditing={initialAccountsEditing}
645
+ lastUsedLabel={lastUsedLabel}
646
+ lastUsedMethod={lastUsedMethod}
647
+ onContinue={onContinue!}
648
+ onForget={onForget}
649
+ testID={testID}
650
+ />
651
+ )}
652
+ {hasAccounts && (hasMethods || hasForm) && !showMethods && (
653
+ <Button
654
+ disabled={loading}
655
+ fullWidth
656
+ onClick={expandMethods}
657
+ testID={`${testID}-another-way`}
658
+ text="Sign in another way"
659
+ variant="muted"
660
+ />
661
+ )}
662
+ {showMethods && hasAccounts && hasMethods && (
663
+ <MethodDivider text="or sign in another way" />
664
+ )}
665
+ {showMethods && hasMethods && renderMethodStack()}
666
+ {showMethods && hasForm && hasMethods && <MethodDivider text="or use your email" />}
667
+ {showMethods && hasForm && (
668
+ <FormContainer
669
+ accessibilityLabel={resolvedTitle}
670
+ gap={4}
671
+ onSubmit={handleSubmit}
672
+ ref={formRef}
673
+ testID={`${testID}-form`}
674
+ width="100%"
675
+ >
676
+ {visibleFields.map((field, index) => renderField(field, index, visibleFields))}
677
+ <Button
678
+ accessibilityLabel={
679
+ isEmailLastUsed
680
+ ? withLastUsedLabel({label: "Sign in", lastUsedLabel})
681
+ : undefined
682
+ }
683
+ disabled={isSubmitDisabled}
684
+ fullWidth
685
+ loading={loading}
686
+ onClick={requestSubmit}
687
+ testID={`${testID}-submit-button`}
688
+ text={loading ? "Signing in" : "Sign in"}
689
+ />
690
+ </FormContainer>
691
+ )}
692
+ </Box>
693
+ )}
694
+ </Box>
695
+ {renderFooter()}
696
+ </Box>
697
+ </View>
162
698
  </Page>
163
699
  );
164
700
  };
701
+
702
+ const IdentityChip: FC<{
703
+ account: LoginAccountOption;
704
+ who: string;
705
+ onNotYou: () => void;
706
+ disabled: boolean;
707
+ testID: string;
708
+ }> = ({account, who, onNotYou, disabled, testID}) => {
709
+ const {theme} = useTheme();
710
+ if (!theme) {
711
+ return null;
712
+ }
713
+ return (
714
+ <View
715
+ style={{
716
+ alignItems: "center",
717
+ backgroundColor: theme.surface.secondaryExtraLight,
718
+ borderColor: theme.surface.secondaryLight,
719
+ borderRadius: theme.radius.full,
720
+ borderWidth: 1,
721
+ flexDirection: "row",
722
+ gap: 12,
723
+ paddingHorizontal: 16,
724
+ paddingVertical: 12,
725
+ width: "100%",
726
+ }}
727
+ >
728
+ <AvatarOrIcon account={account} who={who} />
729
+ <Box flex="shrink">
730
+ <Text bold>{account.name ?? who}</Text>
731
+ {Boolean(account.email) && (
732
+ <Text color="secondaryLight" size="sm">
733
+ {account.email}
734
+ </Text>
735
+ )}
736
+ </Box>
737
+ <TextLink disabled={disabled} onPress={onNotYou} testID={testID} text="Not you?" />
738
+ </View>
739
+ );
740
+ };
741
+
742
+ const AvatarOrIcon: FC<{account: LoginAccountOption; who: string}> = ({account, who}) => {
743
+ if (account.name || account.email) {
744
+ return <Avatar name={account.name ?? account.email ?? who} size="sm" src={account.image} />;
745
+ }
746
+ return <Icon color="secondaryLight" iconName="circle-user" size="xl" />;
747
+ };