@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
@@ -0,0 +1,371 @@
1
+ import {describe, expect, it, mock, spyOn} from "bun:test";
2
+ import {act, fireEvent, waitFor} from "@testing-library/react-native";
3
+ import {DateTime} from "luxon";
4
+ import {ActivityIndicator} from "react-native";
5
+
6
+ import {renderWithTheme} from "../test-utils";
7
+ import {LinkedAccountsCard} from "./LinkedAccountsCard";
8
+ import type {LinkableProvider, LinkedAccount} from "./securityTypes";
9
+
10
+ const PROVIDERS: LinkableProvider[] = [{id: "google"}, {id: "github"}];
11
+
12
+ const LINKED_AT = "2026-03-03T12:00:00.000Z";
13
+ // Computed with Luxon so the expectation follows the test runner's locale and time zone.
14
+ const LINKED_DATE = DateTime.fromISO(LINKED_AT).toLocaleString(DateTime.DATE_MED);
15
+
16
+ const GOOGLE: LinkedAccount = {
17
+ accountId: "g-1",
18
+ email: "ada@example.com",
19
+ id: "acc-google",
20
+ linkedAt: LINKED_AT,
21
+ providerId: "google",
22
+ };
23
+ const CREDENTIAL: LinkedAccount = {
24
+ accountId: "u-1",
25
+ id: "acc-credential",
26
+ providerId: "credential",
27
+ };
28
+
29
+ const press = async (element: Parameters<typeof fireEvent.press>[0]): Promise<void> => {
30
+ await act(async () => {
31
+ fireEvent.press(element);
32
+ });
33
+ };
34
+
35
+ const isDisabled = (element: {props: Record<string, unknown>}): boolean => {
36
+ const state = element.props.accessibilityState as {disabled?: boolean} | undefined;
37
+ return Boolean(state?.disabled);
38
+ };
39
+
40
+ describe("LinkedAccountsCard", () => {
41
+ it("lists linked providers with email and linked date, and unlinked ones with Link", () => {
42
+ const {getByTestId, queryByTestId} = renderWithTheme(
43
+ <LinkedAccountsCard
44
+ accounts={[GOOGLE, CREDENTIAL]}
45
+ onLink={mock(() => Promise.resolve())}
46
+ onUnlink={mock(() => Promise.resolve())}
47
+ providers={PROVIDERS}
48
+ />
49
+ );
50
+ expect(getByTestId("linked-accounts-card")).toBeTruthy();
51
+ expect(getByTestId("linked-accounts-card-name-google").props.children).toBe("Google");
52
+ const googleStatus = String(getByTestId("linked-accounts-card-status-google").props.children);
53
+ expect(googleStatus).toContain("ada@example.com");
54
+ expect(googleStatus).toContain(`Linked ${LINKED_DATE}`);
55
+ expect(getByTestId("linked-accounts-card-unlink-google")).toBeTruthy();
56
+ expect(queryByTestId("linked-accounts-card-link-google")).toBeNull();
57
+
58
+ expect(getByTestId("linked-accounts-card-status-github").props.children).toBe("Not linked");
59
+ expect(getByTestId("linked-accounts-card-link-github")).toBeTruthy();
60
+ expect(queryByTestId("linked-accounts-card-unlink-github")).toBeNull();
61
+ });
62
+
63
+ it("does not list the password credential as a provider row", () => {
64
+ const {queryByTestId} = renderWithTheme(
65
+ <LinkedAccountsCard accounts={[GOOGLE, CREDENTIAL]} providers={PROVIDERS} />
66
+ );
67
+ expect(queryByTestId("linked-accounts-card-row-credential")).toBeNull();
68
+ });
69
+
70
+ it("lists a linked account whose provider the app no longer offers", () => {
71
+ const {getByTestId} = renderWithTheme(
72
+ <LinkedAccountsCard
73
+ accounts={[CREDENTIAL, {accountId: "m-1", id: "acc-mock", providerId: "mock-oidc"}]}
74
+ providers={PROVIDERS}
75
+ />
76
+ );
77
+ expect(getByTestId("linked-accounts-card-row-mock-oidc")).toBeTruthy();
78
+ expect(getByTestId("linked-accounts-card-name-mock-oidc").props.children).toBe("mock-oidc");
79
+ });
80
+
81
+ it("uses a provider's label for generic providers", () => {
82
+ const {getByTestId} = renderWithTheme(
83
+ <LinkedAccountsCard accounts={[]} providers={[{id: "mock-oidc", label: "Company SSO"}]} />
84
+ );
85
+ expect(getByTestId("linked-accounts-card-name-mock-oidc").props.children).toBe("Company SSO");
86
+ });
87
+
88
+ it("omits the linked date when linkedAt is not a valid date", () => {
89
+ const {getByTestId} = renderWithTheme(
90
+ <LinkedAccountsCard
91
+ accounts={[{...GOOGLE, linkedAt: "not-a-date"}, CREDENTIAL]}
92
+ providers={PROVIDERS}
93
+ />
94
+ );
95
+ const status = String(getByTestId("linked-accounts-card-status-google").props.children);
96
+ expect(status).toBe("ada@example.com");
97
+ });
98
+
99
+ it("formats a Date linkedAt, as the Better Auth client returns it", () => {
100
+ const linkedAt = new Date(LINKED_AT);
101
+ const {getByTestId} = renderWithTheme(
102
+ <LinkedAccountsCard
103
+ accounts={[{id: "acc-gh", linkedAt, providerId: "github"}, CREDENTIAL]}
104
+ providers={PROVIDERS}
105
+ />
106
+ );
107
+ expect(getByTestId("linked-accounts-card-status-github").props.children).toBe(
108
+ `Linked ${DateTime.fromJSDate(linkedAt).toLocaleString(DateTime.DATE_MED)}`
109
+ );
110
+ });
111
+
112
+ it("gives each linked account of one provider its own unlinkable row", async () => {
113
+ const work: LinkedAccount = {
114
+ email: "ada@work.example",
115
+ id: "acc-google-2",
116
+ providerId: "google",
117
+ };
118
+ const onUnlink = mock((_providerId: string, _account: LinkedAccount) => Promise.resolve());
119
+ const {getByTestId, queryByTestId} = renderWithTheme(
120
+ <LinkedAccountsCard
121
+ accounts={[GOOGLE, work, CREDENTIAL]}
122
+ onLink={mock(() => Promise.resolve())}
123
+ onUnlink={onUnlink}
124
+ providers={PROVIDERS}
125
+ />
126
+ );
127
+ expect(getByTestId("linked-accounts-card-unlink-google")).toBeTruthy();
128
+ expect(getByTestId("linked-accounts-card-unlink-google-2")).toBeTruthy();
129
+ expect(queryByTestId("linked-accounts-card-link-google")).toBeNull();
130
+ expect(getByTestId("linked-accounts-card-link-github")).toBeTruthy();
131
+
132
+ await press(getByTestId("linked-accounts-card-unlink-google-2"));
133
+ await waitFor(() => {
134
+ expect(getByTestId("linked-accounts-card-confirm-submit")).toBeTruthy();
135
+ });
136
+ await press(getByTestId("linked-accounts-card-confirm-submit"));
137
+ await waitFor(() => {
138
+ expect(onUnlink).toHaveBeenCalledWith("google", work);
139
+ });
140
+ });
141
+
142
+ it("disables every button with the disabled prop", () => {
143
+ const {getByTestId} = renderWithTheme(
144
+ <LinkedAccountsCard
145
+ accounts={[GOOGLE, CREDENTIAL]}
146
+ disabled
147
+ onLink={mock(() => Promise.resolve())}
148
+ onUnlink={mock(() => Promise.resolve())}
149
+ providers={PROVIDERS}
150
+ />
151
+ );
152
+ expect(isDisabled(getByTestId("linked-accounts-card-unlink-google"))).toBe(true);
153
+ expect(isDisabled(getByTestId("linked-accounts-card-link-github"))).toBe(true);
154
+ });
155
+
156
+ it("shows a spinner on the unlinking row and disables the others until unlink settles", async () => {
157
+ let resolveUnlink: () => void = () => {};
158
+ const onUnlink = mock(
159
+ (_providerId: string, _account: LinkedAccount) =>
160
+ new Promise<void>((resolve) => {
161
+ resolveUnlink = resolve;
162
+ })
163
+ );
164
+ const {getByTestId} = renderWithTheme(
165
+ <LinkedAccountsCard
166
+ accounts={[GOOGLE, CREDENTIAL]}
167
+ onLink={mock(() => Promise.resolve())}
168
+ onUnlink={onUnlink}
169
+ providers={PROVIDERS}
170
+ />
171
+ );
172
+ await press(getByTestId("linked-accounts-card-unlink-google"));
173
+ await waitFor(() => {
174
+ expect(getByTestId("linked-accounts-card-confirm-submit")).toBeTruthy();
175
+ });
176
+ await press(getByTestId("linked-accounts-card-confirm-submit"));
177
+ await waitFor(() => {
178
+ expect(onUnlink).toHaveBeenCalled();
179
+ });
180
+ const unlinkButton = getByTestId("linked-accounts-card-unlink-google");
181
+ expect(isDisabled(unlinkButton)).toBe(true);
182
+ expect(unlinkButton.findAllByType(ActivityIndicator).length).toBe(1);
183
+ const linkButton = getByTestId("linked-accounts-card-link-github");
184
+ expect(isDisabled(linkButton)).toBe(true);
185
+ expect(linkButton.findAllByType(ActivityIndicator).length).toBe(0);
186
+
187
+ await act(async () => {
188
+ resolveUnlink();
189
+ });
190
+ await waitFor(() => {
191
+ expect(isDisabled(getByTestId("linked-accounts-card-link-github"))).toBe(false);
192
+ });
193
+ expect(
194
+ getByTestId("linked-accounts-card-unlink-google").findAllByType(ActivityIndicator).length
195
+ ).toBe(0);
196
+ });
197
+
198
+ it("calls onLink with the provider id and shows a spinner on that row while pending", async () => {
199
+ let resolveLink: () => void = () => {};
200
+ const onLink = mock(
201
+ (_providerId: string) =>
202
+ new Promise<void>((resolve) => {
203
+ resolveLink = resolve;
204
+ })
205
+ );
206
+ const {getByTestId} = renderWithTheme(
207
+ <LinkedAccountsCard accounts={[CREDENTIAL]} onLink={onLink} providers={PROVIDERS} />
208
+ );
209
+ await press(getByTestId("linked-accounts-card-link-github"));
210
+ expect(onLink).toHaveBeenCalledWith("github");
211
+ await waitFor(() => {
212
+ expect(isDisabled(getByTestId("linked-accounts-card-link-github"))).toBe(true);
213
+ expect(isDisabled(getByTestId("linked-accounts-card-link-google"))).toBe(true);
214
+ });
215
+ await act(async () => {
216
+ resolveLink();
217
+ });
218
+ await waitFor(() => {
219
+ expect(isDisabled(getByTestId("linked-accounts-card-link-github"))).toBe(false);
220
+ });
221
+ });
222
+
223
+ it("asks for confirmation before unlinking and unlinks on confirm", async () => {
224
+ const onUnlink = mock((_providerId: string, _account: LinkedAccount) => Promise.resolve());
225
+ const {getByTestId, queryByTestId} = renderWithTheme(
226
+ <LinkedAccountsCard
227
+ accounts={[GOOGLE, CREDENTIAL]}
228
+ onUnlink={onUnlink}
229
+ providers={PROVIDERS}
230
+ />
231
+ );
232
+ expect(queryByTestId("linked-accounts-card-confirm")).toBeNull();
233
+
234
+ await press(getByTestId("linked-accounts-card-unlink-google"));
235
+ await waitFor(() => {
236
+ expect(getByTestId("linked-accounts-card-confirm")).toBeTruthy();
237
+ });
238
+ expect(onUnlink).not.toHaveBeenCalled();
239
+
240
+ await press(getByTestId("linked-accounts-card-confirm-submit"));
241
+ await waitFor(() => {
242
+ expect(onUnlink).toHaveBeenCalledWith("google", GOOGLE);
243
+ });
244
+ await waitFor(() => {
245
+ expect(queryByTestId("linked-accounts-card-confirm")).toBeNull();
246
+ });
247
+ });
248
+
249
+ it("does not unlink when the confirmation is cancelled", async () => {
250
+ const onUnlink = mock((_providerId: string, _account: LinkedAccount) => Promise.resolve());
251
+ const {getByTestId, queryByTestId} = renderWithTheme(
252
+ <LinkedAccountsCard
253
+ accounts={[GOOGLE, CREDENTIAL]}
254
+ onUnlink={onUnlink}
255
+ providers={PROVIDERS}
256
+ />
257
+ );
258
+ await press(getByTestId("linked-accounts-card-unlink-google"));
259
+ await waitFor(() => {
260
+ expect(getByTestId("linked-accounts-card-confirm-cancel")).toBeTruthy();
261
+ });
262
+ await press(getByTestId("linked-accounts-card-confirm-cancel"));
263
+ await waitFor(() => {
264
+ expect(queryByTestId("linked-accounts-card-confirm")).toBeNull();
265
+ });
266
+ expect(onUnlink).not.toHaveBeenCalled();
267
+ });
268
+
269
+ it("disables Unlink with an explanation when it is the only sign-in method", () => {
270
+ const {getByTestId} = renderWithTheme(
271
+ <LinkedAccountsCard
272
+ accounts={[GOOGLE]}
273
+ onUnlink={mock(() => Promise.resolve())}
274
+ providers={PROVIDERS}
275
+ />
276
+ );
277
+ expect(isDisabled(getByTestId("linked-accounts-card-unlink-google"))).toBe(true);
278
+ expect(getByTestId("linked-accounts-card-last-method-google")).toBeTruthy();
279
+ });
280
+
281
+ it("allows Unlink when the user also has a password", () => {
282
+ const {getByTestId, queryByTestId} = renderWithTheme(
283
+ <LinkedAccountsCard
284
+ accounts={[GOOGLE, CREDENTIAL]}
285
+ onUnlink={mock(() => Promise.resolve())}
286
+ providers={PROVIDERS}
287
+ />
288
+ );
289
+ expect(isDisabled(getByTestId("linked-accounts-card-unlink-google"))).toBe(false);
290
+ expect(queryByTestId("linked-accounts-card-last-method-google")).toBeNull();
291
+ });
292
+
293
+ it("counts passkeys passed as otherMethodCount as a sign-in method", () => {
294
+ const {getByTestId} = renderWithTheme(
295
+ <LinkedAccountsCard
296
+ accounts={[GOOGLE]}
297
+ onUnlink={mock(() => Promise.resolve())}
298
+ otherMethodCount={1}
299
+ providers={PROVIDERS}
300
+ />
301
+ );
302
+ expect(isDisabled(getByTestId("linked-accounts-card-unlink-google"))).toBe(false);
303
+ });
304
+
305
+ it("allows unlinking the last method with canUnlinkLast", () => {
306
+ const {getByTestId, queryByTestId} = renderWithTheme(
307
+ <LinkedAccountsCard
308
+ accounts={[GOOGLE]}
309
+ canUnlinkLast
310
+ onUnlink={mock(() => Promise.resolve())}
311
+ providers={PROVIDERS}
312
+ />
313
+ );
314
+ expect(isDisabled(getByTestId("linked-accounts-card-unlink-google"))).toBe(false);
315
+ expect(queryByTestId("linked-accounts-card-last-method-google")).toBeNull();
316
+ });
317
+
318
+ it("shows a rejected unlink's message as an alert", async () => {
319
+ const warn = spyOn(console, "warn").mockImplementation(() => {});
320
+ const onUnlink = mock((_providerId: string, _account: LinkedAccount) =>
321
+ Promise.reject(new Error("You can't unlink your last account"))
322
+ );
323
+ const {getByTestId} = renderWithTheme(
324
+ <LinkedAccountsCard
325
+ accounts={[GOOGLE, CREDENTIAL]}
326
+ onUnlink={onUnlink}
327
+ providers={PROVIDERS}
328
+ />
329
+ );
330
+ await press(getByTestId("linked-accounts-card-unlink-google"));
331
+ await waitFor(() => {
332
+ expect(getByTestId("linked-accounts-card-confirm-submit")).toBeTruthy();
333
+ });
334
+ await press(getByTestId("linked-accounts-card-confirm-submit"));
335
+ await waitFor(() => {
336
+ expect(getByTestId("linked-accounts-card-error")).toBeTruthy();
337
+ });
338
+ expect(getByTestId("linked-accounts-card-error").props.role).toBe("alert");
339
+ expect(isDisabled(getByTestId("linked-accounts-card-unlink-google"))).toBe(false);
340
+ warn.mockRestore();
341
+ });
342
+
343
+ it("shows the error prop as an alert", () => {
344
+ const {getByTestId, getByText} = renderWithTheme(
345
+ <LinkedAccountsCard accounts={[]} error="Linking failed" providers={PROVIDERS} />
346
+ );
347
+ expect(getByTestId("linked-accounts-card-error").props.role).toBe("alert");
348
+ expect(getByText("Linking failed")).toBeTruthy();
349
+ });
350
+
351
+ it("names the Link and Unlink buttons after their provider", () => {
352
+ const {getByLabelText} = renderWithTheme(
353
+ <LinkedAccountsCard
354
+ accounts={[GOOGLE, CREDENTIAL]}
355
+ onLink={mock(() => Promise.resolve())}
356
+ onUnlink={mock(() => Promise.resolve())}
357
+ providers={PROVIDERS}
358
+ />
359
+ );
360
+ expect(getByLabelText("Unlink Google (ada@example.com)")).toBeTruthy();
361
+ expect(getByLabelText("Link GitHub")).toBeTruthy();
362
+ });
363
+
364
+ it("hides the buttons when no callbacks are given", () => {
365
+ const {queryByTestId} = renderWithTheme(
366
+ <LinkedAccountsCard accounts={[GOOGLE, CREDENTIAL]} providers={PROVIDERS} />
367
+ );
368
+ expect(queryByTestId("linked-accounts-card-unlink-google")).toBeNull();
369
+ expect(queryByTestId("linked-accounts-card-link-github")).toBeNull();
370
+ });
371
+ });
@@ -0,0 +1,297 @@
1
+ import {type FC, useCallback, useMemo, useState} from "react";
2
+ import {View} from "react-native";
3
+
4
+ import {Box} from "../Box";
5
+ import {Button} from "../Button";
6
+ import {Card} from "../Card";
7
+ import {Heading} from "../Heading";
8
+ import {Icon} from "../Icon";
9
+ import {Modal} from "../Modal";
10
+ import {Text} from "../Text";
11
+ import {
12
+ CREDENTIAL_PROVIDER_ID,
13
+ formatSecurityDate,
14
+ getProviderDisplay,
15
+ getRejectionMessage,
16
+ type ProviderDisplay,
17
+ } from "./securityMethods";
18
+ import type {LinkableProvider, LinkedAccount, LinkedAccountsCardProps} from "./securityTypes";
19
+
20
+ /** One row: a linked account, or an offered provider with no linked account. */
21
+ interface ProviderRow {
22
+ /** React key: the account id, or the provider id for an unlinked row. */
23
+ key: string;
24
+ /** testID suffix: the provider id, plus `-2`, `-3`, ... for a provider's later accounts. */
25
+ testIDSuffix: string;
26
+ providerId: string;
27
+ display: ProviderDisplay;
28
+ account?: LinkedAccount;
29
+ }
30
+
31
+ /**
32
+ * Builds one row per linked account (so two Google accounts are each unlinkable), grouped under
33
+ * the offered providers in order, with a Link row for each offered provider that has none.
34
+ * Accounts for providers the app no longer offers follow.
35
+ */
36
+ const buildRows = ({
37
+ accounts,
38
+ providers,
39
+ }: {
40
+ accounts: LinkedAccount[];
41
+ providers: LinkableProvider[];
42
+ }): ProviderRow[] => {
43
+ const socialAccounts = accounts.filter(
44
+ (account) => account.providerId !== CREDENTIAL_PROVIDER_ID
45
+ );
46
+ const offeredIds = new Set(providers.map((provider) => provider.id));
47
+ const accountRows = (providerId: string, display: ProviderDisplay): ProviderRow[] => {
48
+ return socialAccounts
49
+ .filter((account) => account.providerId === providerId)
50
+ .map((account, index) => ({
51
+ account,
52
+ display,
53
+ key: account.id,
54
+ providerId,
55
+ testIDSuffix: index === 0 ? providerId : `${providerId}-${index + 1}`,
56
+ }));
57
+ };
58
+
59
+ const rows: ProviderRow[] = [];
60
+ for (const provider of providers) {
61
+ const display = getProviderDisplay({provider, providerId: provider.id});
62
+ const linkedRows = accountRows(provider.id, display);
63
+ if (linkedRows.length > 0) {
64
+ rows.push(...linkedRows);
65
+ } else {
66
+ rows.push({display, key: provider.id, providerId: provider.id, testIDSuffix: provider.id});
67
+ }
68
+ }
69
+ const extraProviderIds = [...new Set(socialAccounts.map((account) => account.providerId))].filter(
70
+ (providerId) => !offeredIds.has(providerId)
71
+ );
72
+ for (const providerId of extraProviderIds) {
73
+ rows.push(...accountRows(providerId, getProviderDisplay({providerId})));
74
+ }
75
+ return rows;
76
+ };
77
+
78
+ /** "ada@example.com · Linked Mar 3, 2026", or "Linked" when neither is known. */
79
+ const describeLinkedAccount = (account: LinkedAccount): string => {
80
+ const linkedDate = formatSecurityDate(account.linkedAt);
81
+ const parts = [account.email, linkedDate ? `Linked ${linkedDate}` : undefined].filter(
82
+ (part): part is string => Boolean(part)
83
+ );
84
+ return parts.length > 0 ? parts.join(" · ") : "Linked";
85
+ };
86
+
87
+ /**
88
+ * Lists the sign-in providers an app offers, each linked (with its email and linked date) or not,
89
+ * with Link and Unlink buttons. Unlink asks for confirmation, and is disabled with an explanation
90
+ * when the account is the user's last way to sign in. Presentational: it reports actions through
91
+ * `onLink` and `onUnlink` and never calls an auth client itself.
92
+ *
93
+ * @example
94
+ * ```tsx
95
+ * <LinkedAccountsCard
96
+ * accounts={accounts} // listAccounts() entries as LinkedAccount ({id, providerId, linkedAt: createdAt})
97
+ * providers={[{id: "google"}, {id: "github"}]}
98
+ * otherMethodCount={passkeys.length}
99
+ * onLink={async (providerId) => {
100
+ * const {error} = await authClient.linkSocial({provider: providerId, callbackURL});
101
+ * if (error) {
102
+ * throw new Error(error.message ?? "Couldn't link that account.");
103
+ * }
104
+ * }}
105
+ * onUnlink={async (_providerId, account) => {
106
+ * // The Better Auth client resolves {data, error} rather than throwing.
107
+ * const {error} = await authClient.unlinkAccount({accountId: account.id});
108
+ * if (error) {
109
+ * throw new Error(error.message ?? "Couldn't unlink that account.");
110
+ * }
111
+ * }}
112
+ * />
113
+ * ```
114
+ */
115
+ export const LinkedAccountsCard: FC<LinkedAccountsCardProps> = ({
116
+ accounts,
117
+ providers,
118
+ onLink,
119
+ onUnlink,
120
+ otherMethodCount = 0,
121
+ canUnlinkLast = false,
122
+ error,
123
+ disabled = false,
124
+ title = "Linked accounts",
125
+ description = "Sign in with any account linked here.",
126
+ testID = "linked-accounts-card",
127
+ }) => {
128
+ const [pendingRowKey, setPendingRowKey] = useState<string | undefined>(undefined);
129
+ const [confirmRow, setConfirmRow] = useState<ProviderRow | undefined>(undefined);
130
+ const [actionError, setActionError] = useState<string | undefined>(undefined);
131
+
132
+ const rows = useMemo(() => buildRows({accounts, providers}), [accounts, providers]);
133
+ const isLastMethod = accounts.length + otherMethodCount <= 1;
134
+ const isBusy = disabled || pendingRowKey !== undefined;
135
+ const shownError = error ?? actionError;
136
+
137
+ const runAction = useCallback(
138
+ async ({
139
+ rowKey,
140
+ action,
141
+ fallback,
142
+ }: {
143
+ rowKey: string;
144
+ action: () => void | Promise<void>;
145
+ fallback: string;
146
+ }): Promise<void> => {
147
+ setActionError(undefined);
148
+ setPendingRowKey(rowKey);
149
+ try {
150
+ await action();
151
+ } catch (rejection: unknown) {
152
+ console.warn("LinkedAccountsCard: action rejected", rejection);
153
+ setActionError(getRejectionMessage({error: rejection, fallback}));
154
+ } finally {
155
+ setPendingRowKey(undefined);
156
+ }
157
+ },
158
+ []
159
+ );
160
+
161
+ const handleLink = useCallback(
162
+ async (row: ProviderRow): Promise<void> => {
163
+ if (!onLink || isBusy) {
164
+ return;
165
+ }
166
+ await runAction({
167
+ action: () => onLink(row.providerId),
168
+ fallback: `Couldn't link ${row.display.label}. Try again.`,
169
+ rowKey: row.key,
170
+ });
171
+ },
172
+ [isBusy, onLink, runAction]
173
+ );
174
+
175
+ const handleDismissConfirm = useCallback((): void => {
176
+ setConfirmRow(undefined);
177
+ }, []);
178
+
179
+ const handleConfirmUnlink = useCallback(async (): Promise<void> => {
180
+ const row = confirmRow;
181
+ setConfirmRow(undefined);
182
+ if (!row?.account || !onUnlink) {
183
+ return;
184
+ }
185
+ const account = row.account;
186
+ await runAction({
187
+ action: () => onUnlink(row.providerId, account),
188
+ fallback: `Couldn't unlink ${row.display.label}. Try again.`,
189
+ rowKey: row.key,
190
+ });
191
+ }, [confirmRow, onUnlink, runAction]);
192
+
193
+ return (
194
+ <Card testID={testID}>
195
+ <Box gap={4}>
196
+ <Box gap={1}>
197
+ <Heading level={2} size="md" testID={`${testID}-title`}>
198
+ {title}
199
+ </Heading>
200
+ <Text color="secondaryLight">{description}</Text>
201
+ </Box>
202
+
203
+ {rows.map((row) => {
204
+ const {account, display, key, testIDSuffix} = row;
205
+ const isPending = pendingRowKey === key;
206
+ const isUnlinkBlocked = Boolean(account) && isLastMethod && !canUnlinkLast;
207
+ return (
208
+ <Box gap={1} key={key} testID={`${testID}-row-${testIDSuffix}`}>
209
+ <Box alignItems="center" direction="row" gap={3}>
210
+ <Box alignItems="center" width={24}>
211
+ <Icon iconName={display.iconName} size="lg" type={display.iconType} />
212
+ </Box>
213
+ <Box flex="grow" gap={1}>
214
+ <Text bold testID={`${testID}-name-${testIDSuffix}`}>
215
+ {display.label}
216
+ </Text>
217
+ <Text
218
+ color="secondaryLight"
219
+ size="sm"
220
+ testID={`${testID}-status-${testIDSuffix}`}
221
+ >
222
+ {account ? describeLinkedAccount(account) : "Not linked"}
223
+ </Text>
224
+ </Box>
225
+ {account && Boolean(onUnlink) && (
226
+ <Button
227
+ accessibilityLabel={
228
+ account.email
229
+ ? `Unlink ${display.label} (${account.email})`
230
+ : `Unlink ${display.label}`
231
+ }
232
+ disabled={isBusy || isUnlinkBlocked}
233
+ loading={isPending}
234
+ onClick={() => setConfirmRow(row)}
235
+ size="sm"
236
+ testID={`${testID}-unlink-${testIDSuffix}`}
237
+ text="Unlink"
238
+ variant="outline"
239
+ />
240
+ )}
241
+ {!account && Boolean(onLink) && (
242
+ <Button
243
+ accessibilityLabel={`Link ${display.label}`}
244
+ disabled={isBusy}
245
+ loading={isPending}
246
+ onClick={() => handleLink(row)}
247
+ size="sm"
248
+ testID={`${testID}-link-${testIDSuffix}`}
249
+ text="Link"
250
+ variant="secondary"
251
+ />
252
+ )}
253
+ </Box>
254
+ {isUnlinkBlocked && Boolean(onUnlink) && (
255
+ <Text
256
+ color="secondaryLight"
257
+ size="sm"
258
+ testID={`${testID}-last-method-${testIDSuffix}`}
259
+ >
260
+ {`${display.label} is your only way to sign in. Add a password, a passkey, or another account before unlinking it.`}
261
+ </Text>
262
+ )}
263
+ </Box>
264
+ );
265
+ })}
266
+
267
+ {Boolean(shownError) && (
268
+ <View role="alert" testID={`${testID}-error`}>
269
+ <Text color="error">{shownError}</Text>
270
+ </View>
271
+ )}
272
+ </Box>
273
+
274
+ {confirmRow !== undefined && (
275
+ <Modal
276
+ onDismiss={handleDismissConfirm}
277
+ primaryButtonOnClick={handleConfirmUnlink}
278
+ primaryButtonText="Unlink"
279
+ secondaryButtonOnClick={handleDismissConfirm}
280
+ secondaryButtonText="Cancel"
281
+ testIDs={{
282
+ dismiss: `${testID}-confirm-dismiss`,
283
+ primaryButton: `${testID}-confirm-submit`,
284
+ root: `${testID}-confirm`,
285
+ secondaryButton: `${testID}-confirm-cancel`,
286
+ title: `${testID}-confirm-title`,
287
+ }}
288
+ text={`You won't be able to sign in with ${confirmRow.display.label}${
289
+ confirmRow.account?.email ? ` (${confirmRow.account.email})` : ""
290
+ } anymore. You can link it again later.`}
291
+ title={`Unlink ${confirmRow.display.label}?`}
292
+ visible
293
+ />
294
+ )}
295
+ </Card>
296
+ );
297
+ };