@oxyhq/services 15.0.0 → 17.0.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 (280) hide show
  1. package/lib/commonjs/index.js +25 -55
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/ui/client.js +0 -14
  4. package/lib/commonjs/ui/client.js.map +1 -1
  5. package/lib/commonjs/ui/components/OxyAccountDialog.js +764 -0
  6. package/lib/commonjs/ui/components/OxyAccountDialog.js.map +1 -0
  7. package/lib/commonjs/ui/components/OxyProvider.js +11 -6
  8. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  9. package/lib/commonjs/ui/components/OxySignInButton.js +10 -21
  10. package/lib/commonjs/ui/components/OxySignInButton.js.map +1 -1
  11. package/lib/commonjs/ui/components/ProfileButton.js +25 -112
  12. package/lib/commonjs/ui/components/ProfileButton.js.map +1 -1
  13. package/lib/commonjs/ui/components/RequireOxyAuth.js +299 -0
  14. package/lib/commonjs/ui/components/RequireOxyAuth.js.map +1 -0
  15. package/lib/commonjs/ui/context/OxyContext.js +106 -2
  16. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  17. package/lib/commonjs/ui/hooks/mutations/mutationKeys.js +1 -1
  18. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +10 -10
  19. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  20. package/lib/commonjs/ui/hooks/queries/queryKeys.js +1 -1
  21. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +7 -8
  22. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  23. package/lib/commonjs/ui/hooks/useAuth.js +19 -30
  24. package/lib/commonjs/ui/hooks/useAuth.js.map +1 -1
  25. package/lib/commonjs/ui/hooks/useSwitchableAccounts.js +37 -267
  26. package/lib/commonjs/ui/hooks/useSwitchableAccounts.js.map +1 -1
  27. package/lib/commonjs/ui/index.js +5 -40
  28. package/lib/commonjs/ui/index.js.map +1 -1
  29. package/lib/commonjs/ui/navigation/accountDialogManager.js +91 -0
  30. package/lib/commonjs/ui/navigation/accountDialogManager.js.map +1 -0
  31. package/lib/commonjs/ui/navigation/routes.js +0 -2
  32. package/lib/commonjs/ui/navigation/routes.js.map +1 -1
  33. package/lib/commonjs/ui/screens/ConnectedAppsScreen.js +17 -18
  34. package/lib/commonjs/ui/screens/ConnectedAppsScreen.js.map +1 -1
  35. package/lib/commonjs/ui/screens/ManageAccountScreen.js +4 -3
  36. package/lib/commonjs/ui/screens/ManageAccountScreen.js.map +1 -1
  37. package/lib/commonjs/ui/session/createSessionClient.js +10 -2
  38. package/lib/commonjs/ui/session/createSessionClient.js.map +1 -1
  39. package/lib/module/index.js +20 -17
  40. package/lib/module/index.js.map +1 -1
  41. package/lib/module/ui/client.js +1 -2
  42. package/lib/module/ui/client.js.map +1 -1
  43. package/lib/module/ui/components/OxyAccountDialog.js +761 -0
  44. package/lib/module/ui/components/OxyAccountDialog.js.map +1 -0
  45. package/lib/module/ui/components/OxyProvider.js +11 -6
  46. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  47. package/lib/module/ui/components/OxySignInButton.js +10 -21
  48. package/lib/module/ui/components/OxySignInButton.js.map +1 -1
  49. package/lib/module/ui/components/ProfileButton.js +26 -112
  50. package/lib/module/ui/components/ProfileButton.js.map +1 -1
  51. package/lib/module/ui/components/RequireOxyAuth.js +294 -0
  52. package/lib/module/ui/components/RequireOxyAuth.js.map +1 -0
  53. package/lib/module/ui/context/OxyContext.js +107 -3
  54. package/lib/module/ui/context/OxyContext.js.map +1 -1
  55. package/lib/module/ui/hooks/mutations/mutationKeys.js +1 -1
  56. package/lib/module/ui/hooks/mutations/useAccountMutations.js +8 -8
  57. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  58. package/lib/module/ui/hooks/queries/queryKeys.js +1 -1
  59. package/lib/module/ui/hooks/queries/useAccountQueries.js +5 -6
  60. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  61. package/lib/module/ui/hooks/useAuth.js +19 -30
  62. package/lib/module/ui/hooks/useAuth.js.map +1 -1
  63. package/lib/module/ui/hooks/useSwitchableAccounts.js +38 -267
  64. package/lib/module/ui/hooks/useSwitchableAccounts.js.map +1 -1
  65. package/lib/module/ui/index.js +1 -5
  66. package/lib/module/ui/index.js.map +1 -1
  67. package/lib/module/ui/navigation/accountDialogManager.js +81 -0
  68. package/lib/module/ui/navigation/accountDialogManager.js.map +1 -0
  69. package/lib/module/ui/navigation/routes.js +0 -2
  70. package/lib/module/ui/navigation/routes.js.map +1 -1
  71. package/lib/module/ui/screens/ConnectedAppsScreen.js +19 -20
  72. package/lib/module/ui/screens/ConnectedAppsScreen.js.map +1 -1
  73. package/lib/module/ui/screens/ManageAccountScreen.js +4 -3
  74. package/lib/module/ui/screens/ManageAccountScreen.js.map +1 -1
  75. package/lib/module/ui/session/createSessionClient.js +10 -2
  76. package/lib/module/ui/session/createSessionClient.js.map +1 -1
  77. package/lib/typescript/commonjs/index.d.ts +6 -13
  78. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/ui/client.d.ts +0 -4
  80. package/lib/typescript/commonjs/ui/client.d.ts.map +1 -1
  81. package/lib/typescript/commonjs/ui/components/OxyAccountDialog.d.ts +35 -0
  82. package/lib/typescript/commonjs/ui/components/OxyAccountDialog.d.ts.map +1 -0
  83. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts +2 -2
  84. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/ui/components/OxySignInButton.d.ts.map +1 -1
  86. package/lib/typescript/commonjs/ui/components/ProfileButton.d.ts +11 -23
  87. package/lib/typescript/commonjs/ui/components/ProfileButton.d.ts.map +1 -1
  88. package/lib/typescript/commonjs/ui/components/RequireOxyAuth.d.ts +55 -0
  89. package/lib/typescript/commonjs/ui/components/RequireOxyAuth.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts +13 -1
  91. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +4 -4
  93. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts +6 -7
  95. package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/ui/hooks/useAuth.d.ts.map +1 -1
  97. package/lib/typescript/commonjs/ui/hooks/useSwitchableAccounts.d.ts +13 -152
  98. package/lib/typescript/commonjs/ui/hooks/useSwitchableAccounts.d.ts.map +1 -1
  99. package/lib/typescript/commonjs/ui/index.d.ts +2 -5
  100. package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
  101. package/lib/typescript/commonjs/ui/navigation/accountDialogManager.d.ts +49 -0
  102. package/lib/typescript/commonjs/ui/navigation/accountDialogManager.d.ts.map +1 -0
  103. package/lib/typescript/commonjs/ui/navigation/routes.d.ts +1 -1
  104. package/lib/typescript/commonjs/ui/navigation/routes.d.ts.map +1 -1
  105. package/lib/typescript/commonjs/ui/screens/ConnectedAppsScreen.d.ts.map +1 -1
  106. package/lib/typescript/commonjs/ui/screens/ManageAccountScreen.d.ts +1 -1
  107. package/lib/typescript/commonjs/ui/screens/ManageAccountScreen.d.ts.map +1 -1
  108. package/lib/typescript/commonjs/ui/session/createSessionClient.d.ts +9 -2
  109. package/lib/typescript/commonjs/ui/session/createSessionClient.d.ts.map +1 -1
  110. package/lib/typescript/commonjs/ui/types/navigation.d.ts +9 -0
  111. package/lib/typescript/commonjs/ui/types/navigation.d.ts.map +1 -1
  112. package/lib/typescript/commonjs/ui/utils/storageHelpers.d.ts +7 -7
  113. package/lib/typescript/module/index.d.ts +6 -13
  114. package/lib/typescript/module/index.d.ts.map +1 -1
  115. package/lib/typescript/module/ui/client.d.ts +0 -4
  116. package/lib/typescript/module/ui/client.d.ts.map +1 -1
  117. package/lib/typescript/module/ui/components/OxyAccountDialog.d.ts +35 -0
  118. package/lib/typescript/module/ui/components/OxyAccountDialog.d.ts.map +1 -0
  119. package/lib/typescript/module/ui/components/OxyProvider.d.ts +2 -2
  120. package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
  121. package/lib/typescript/module/ui/components/OxySignInButton.d.ts.map +1 -1
  122. package/lib/typescript/module/ui/components/ProfileButton.d.ts +11 -23
  123. package/lib/typescript/module/ui/components/ProfileButton.d.ts.map +1 -1
  124. package/lib/typescript/module/ui/components/RequireOxyAuth.d.ts +55 -0
  125. package/lib/typescript/module/ui/components/RequireOxyAuth.d.ts.map +1 -0
  126. package/lib/typescript/module/ui/context/OxyContext.d.ts +13 -1
  127. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  128. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +4 -4
  129. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  130. package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts +6 -7
  131. package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  132. package/lib/typescript/module/ui/hooks/useAuth.d.ts.map +1 -1
  133. package/lib/typescript/module/ui/hooks/useSwitchableAccounts.d.ts +13 -152
  134. package/lib/typescript/module/ui/hooks/useSwitchableAccounts.d.ts.map +1 -1
  135. package/lib/typescript/module/ui/index.d.ts +2 -5
  136. package/lib/typescript/module/ui/index.d.ts.map +1 -1
  137. package/lib/typescript/module/ui/navigation/accountDialogManager.d.ts +49 -0
  138. package/lib/typescript/module/ui/navigation/accountDialogManager.d.ts.map +1 -0
  139. package/lib/typescript/module/ui/navigation/routes.d.ts +1 -1
  140. package/lib/typescript/module/ui/navigation/routes.d.ts.map +1 -1
  141. package/lib/typescript/module/ui/screens/ConnectedAppsScreen.d.ts.map +1 -1
  142. package/lib/typescript/module/ui/screens/ManageAccountScreen.d.ts +1 -1
  143. package/lib/typescript/module/ui/screens/ManageAccountScreen.d.ts.map +1 -1
  144. package/lib/typescript/module/ui/session/createSessionClient.d.ts +9 -2
  145. package/lib/typescript/module/ui/session/createSessionClient.d.ts.map +1 -1
  146. package/lib/typescript/module/ui/types/navigation.d.ts +9 -0
  147. package/lib/typescript/module/ui/types/navigation.d.ts.map +1 -1
  148. package/lib/typescript/module/ui/utils/storageHelpers.d.ts +7 -7
  149. package/package.json +4 -4
  150. package/src/index.ts +23 -28
  151. package/src/ui/client.ts +0 -4
  152. package/src/ui/components/OxyAccountDialog.tsx +760 -0
  153. package/src/ui/components/OxyProvider.tsx +12 -6
  154. package/src/ui/components/OxySignInButton.tsx +10 -21
  155. package/src/ui/components/ProfileButton.tsx +23 -126
  156. package/src/ui/components/RequireOxyAuth.tsx +266 -0
  157. package/src/ui/context/OxyContext.tsx +146 -7
  158. package/src/ui/hooks/mutations/mutationKeys.ts +1 -1
  159. package/src/ui/hooks/mutations/useAccountMutations.ts +8 -8
  160. package/src/ui/hooks/queries/queryKeys.ts +1 -1
  161. package/src/ui/hooks/queries/useAccountQueries.ts +8 -9
  162. package/src/ui/hooks/useAuth.ts +19 -31
  163. package/src/ui/hooks/useSwitchableAccounts.ts +42 -376
  164. package/src/ui/index.ts +2 -5
  165. package/src/ui/navigation/accountDialogManager.ts +84 -0
  166. package/src/ui/navigation/routes.ts +1 -5
  167. package/src/ui/screens/ConnectedAppsScreen.tsx +23 -24
  168. package/src/ui/screens/ManageAccountScreen.tsx +3 -2
  169. package/src/ui/session/createSessionClient.ts +9 -1
  170. package/src/ui/types/navigation.ts +9 -0
  171. package/src/ui/utils/storageHelpers.ts +7 -7
  172. package/lib/commonjs/ui/components/AccountMenu.js +0 -598
  173. package/lib/commonjs/ui/components/AccountMenu.js.map +0 -1
  174. package/lib/commonjs/ui/components/AccountMenuButton.js +0 -135
  175. package/lib/commonjs/ui/components/AccountMenuButton.js.map +0 -1
  176. package/lib/commonjs/ui/components/AccountSwitcher.js +0 -780
  177. package/lib/commonjs/ui/components/AccountSwitcher.js.map +0 -1
  178. package/lib/commonjs/ui/components/AnotherDeviceQR.js +0 -116
  179. package/lib/commonjs/ui/components/AnotherDeviceQR.js.map +0 -1
  180. package/lib/commonjs/ui/components/ProfileMenu.js +0 -518
  181. package/lib/commonjs/ui/components/ProfileMenu.js.map +0 -1
  182. package/lib/commonjs/ui/components/SignInAccountChooser.js +0 -189
  183. package/lib/commonjs/ui/components/SignInAccountChooser.js.map +0 -1
  184. package/lib/commonjs/ui/components/SignInModal.js +0 -600
  185. package/lib/commonjs/ui/components/SignInModal.js.map +0 -1
  186. package/lib/commonjs/ui/hooks/useOxyAuthSession.js +0 -501
  187. package/lib/commonjs/ui/hooks/useOxyAuthSession.js.map +0 -1
  188. package/lib/commonjs/ui/hooks/usePasswordSignIn.js +0 -170
  189. package/lib/commonjs/ui/hooks/usePasswordSignIn.js.map +0 -1
  190. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +0 -51
  191. package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +0 -1
  192. package/lib/commonjs/ui/screens/OxyAuthScreen.js +0 -312
  193. package/lib/commonjs/ui/screens/OxyAuthScreen.js.map +0 -1
  194. package/lib/commonjs/utils/deviceFlowSignIn.js +0 -109
  195. package/lib/commonjs/utils/deviceFlowSignIn.js.map +0 -1
  196. package/lib/module/ui/components/AccountMenu.js +0 -593
  197. package/lib/module/ui/components/AccountMenu.js.map +0 -1
  198. package/lib/module/ui/components/AccountMenuButton.js +0 -130
  199. package/lib/module/ui/components/AccountMenuButton.js.map +0 -1
  200. package/lib/module/ui/components/AccountSwitcher.js +0 -774
  201. package/lib/module/ui/components/AccountSwitcher.js.map +0 -1
  202. package/lib/module/ui/components/AnotherDeviceQR.js +0 -110
  203. package/lib/module/ui/components/AnotherDeviceQR.js.map +0 -1
  204. package/lib/module/ui/components/ProfileMenu.js +0 -514
  205. package/lib/module/ui/components/ProfileMenu.js.map +0 -1
  206. package/lib/module/ui/components/SignInAccountChooser.js +0 -183
  207. package/lib/module/ui/components/SignInAccountChooser.js.map +0 -1
  208. package/lib/module/ui/components/SignInModal.js +0 -591
  209. package/lib/module/ui/components/SignInModal.js.map +0 -1
  210. package/lib/module/ui/hooks/useOxyAuthSession.js +0 -495
  211. package/lib/module/ui/hooks/useOxyAuthSession.js.map +0 -1
  212. package/lib/module/ui/hooks/usePasswordSignIn.js +0 -165
  213. package/lib/module/ui/hooks/usePasswordSignIn.js.map +0 -1
  214. package/lib/module/ui/screens/AccountSwitcherScreen.js +0 -48
  215. package/lib/module/ui/screens/AccountSwitcherScreen.js.map +0 -1
  216. package/lib/module/ui/screens/OxyAuthScreen.js +0 -306
  217. package/lib/module/ui/screens/OxyAuthScreen.js.map +0 -1
  218. package/lib/module/utils/deviceFlowSignIn.js +0 -106
  219. package/lib/module/utils/deviceFlowSignIn.js.map +0 -1
  220. package/lib/typescript/commonjs/ui/components/AccountMenu.d.ts +0 -47
  221. package/lib/typescript/commonjs/ui/components/AccountMenu.d.ts.map +0 -1
  222. package/lib/typescript/commonjs/ui/components/AccountMenuButton.d.ts +0 -26
  223. package/lib/typescript/commonjs/ui/components/AccountMenuButton.d.ts.map +0 -1
  224. package/lib/typescript/commonjs/ui/components/AccountSwitcher.d.ts +0 -46
  225. package/lib/typescript/commonjs/ui/components/AccountSwitcher.d.ts.map +0 -1
  226. package/lib/typescript/commonjs/ui/components/AnotherDeviceQR.d.ts +0 -34
  227. package/lib/typescript/commonjs/ui/components/AnotherDeviceQR.d.ts.map +0 -1
  228. package/lib/typescript/commonjs/ui/components/ProfileMenu.d.ts +0 -49
  229. package/lib/typescript/commonjs/ui/components/ProfileMenu.d.ts.map +0 -1
  230. package/lib/typescript/commonjs/ui/components/SignInAccountChooser.d.ts +0 -29
  231. package/lib/typescript/commonjs/ui/components/SignInAccountChooser.d.ts.map +0 -1
  232. package/lib/typescript/commonjs/ui/components/SignInModal.d.ts +0 -28
  233. package/lib/typescript/commonjs/ui/components/SignInModal.d.ts.map +0 -1
  234. package/lib/typescript/commonjs/ui/hooks/useOxyAuthSession.d.ts +0 -105
  235. package/lib/typescript/commonjs/ui/hooks/useOxyAuthSession.d.ts.map +0 -1
  236. package/lib/typescript/commonjs/ui/hooks/usePasswordSignIn.d.ts +0 -31
  237. package/lib/typescript/commonjs/ui/hooks/usePasswordSignIn.d.ts.map +0 -1
  238. package/lib/typescript/commonjs/ui/screens/AccountSwitcherScreen.d.ts +0 -11
  239. package/lib/typescript/commonjs/ui/screens/AccountSwitcherScreen.d.ts.map +0 -1
  240. package/lib/typescript/commonjs/ui/screens/OxyAuthScreen.d.ts +0 -22
  241. package/lib/typescript/commonjs/ui/screens/OxyAuthScreen.d.ts.map +0 -1
  242. package/lib/typescript/commonjs/utils/deviceFlowSignIn.d.ts +0 -97
  243. package/lib/typescript/commonjs/utils/deviceFlowSignIn.d.ts.map +0 -1
  244. package/lib/typescript/module/ui/components/AccountMenu.d.ts +0 -47
  245. package/lib/typescript/module/ui/components/AccountMenu.d.ts.map +0 -1
  246. package/lib/typescript/module/ui/components/AccountMenuButton.d.ts +0 -26
  247. package/lib/typescript/module/ui/components/AccountMenuButton.d.ts.map +0 -1
  248. package/lib/typescript/module/ui/components/AccountSwitcher.d.ts +0 -46
  249. package/lib/typescript/module/ui/components/AccountSwitcher.d.ts.map +0 -1
  250. package/lib/typescript/module/ui/components/AnotherDeviceQR.d.ts +0 -34
  251. package/lib/typescript/module/ui/components/AnotherDeviceQR.d.ts.map +0 -1
  252. package/lib/typescript/module/ui/components/ProfileMenu.d.ts +0 -49
  253. package/lib/typescript/module/ui/components/ProfileMenu.d.ts.map +0 -1
  254. package/lib/typescript/module/ui/components/SignInAccountChooser.d.ts +0 -29
  255. package/lib/typescript/module/ui/components/SignInAccountChooser.d.ts.map +0 -1
  256. package/lib/typescript/module/ui/components/SignInModal.d.ts +0 -28
  257. package/lib/typescript/module/ui/components/SignInModal.d.ts.map +0 -1
  258. package/lib/typescript/module/ui/hooks/useOxyAuthSession.d.ts +0 -105
  259. package/lib/typescript/module/ui/hooks/useOxyAuthSession.d.ts.map +0 -1
  260. package/lib/typescript/module/ui/hooks/usePasswordSignIn.d.ts +0 -31
  261. package/lib/typescript/module/ui/hooks/usePasswordSignIn.d.ts.map +0 -1
  262. package/lib/typescript/module/ui/screens/AccountSwitcherScreen.d.ts +0 -11
  263. package/lib/typescript/module/ui/screens/AccountSwitcherScreen.d.ts.map +0 -1
  264. package/lib/typescript/module/ui/screens/OxyAuthScreen.d.ts +0 -22
  265. package/lib/typescript/module/ui/screens/OxyAuthScreen.d.ts.map +0 -1
  266. package/lib/typescript/module/utils/deviceFlowSignIn.d.ts +0 -97
  267. package/lib/typescript/module/utils/deviceFlowSignIn.d.ts.map +0 -1
  268. package/src/ui/components/AccountMenu.tsx +0 -645
  269. package/src/ui/components/AccountMenuButton.tsx +0 -126
  270. package/src/ui/components/AccountSwitcher.tsx +0 -751
  271. package/src/ui/components/AnotherDeviceQR.tsx +0 -119
  272. package/src/ui/components/ProfileMenu.tsx +0 -564
  273. package/src/ui/components/SignInAccountChooser.tsx +0 -162
  274. package/src/ui/components/SignInModal.tsx +0 -530
  275. package/src/ui/hooks/useOxyAuthSession.ts +0 -635
  276. package/src/ui/hooks/usePasswordSignIn.ts +0 -207
  277. package/src/ui/screens/AccountSwitcherScreen.tsx +0 -43
  278. package/src/ui/screens/OxyAuthScreen.tsx +0 -324
  279. package/src/utils/__tests__/deviceFlowSignIn.test.ts +0 -231
  280. package/src/utils/deviceFlowSignIn.ts +0 -152
@@ -1,774 +0,0 @@
1
- "use strict";
2
-
3
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
- import { View, Text, TextInput, TouchableOpacity, StyleSheet, ScrollView, Modal, Pressable, Platform, ActivityIndicator } from 'react-native';
5
- import { Ionicons } from '@expo/vector-icons';
6
- import { toast, useDialogControl, Dialog } from '@oxyhq/bloom';
7
- import { Divider } from '@oxyhq/bloom/divider';
8
- import { useTheme } from '@oxyhq/bloom/theme';
9
- import { isDev, logger as loggerUtil } from '@oxyhq/core';
10
- import Avatar from "./Avatar.js";
11
- import { useOxy } from "../context/OxyContext.js";
12
- import { useI18n } from "../hooks/useI18n.js";
13
- import { useSwitchableAccounts } from "../hooks/useSwitchableAccounts.js";
14
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
15
- const isWeb = Platform.OS === 'web';
16
- const PANEL_WIDTH = 380;
17
-
18
- /**
19
- * The set of action callbacks the switcher body needs. Supplied by whichever
20
- * chrome wraps it — the {@link AccountSwitcher} modal/popover (web header chip,
21
- * native sheet) or the {@link AccountSwitcherScreen} bottom-sheet route.
22
- */
23
-
24
- /**
25
- * Group flat account rows into a 2-level tree (org → direct children). A row
26
- * whose parent is not in the set is treated as a root; any deeper row not
27
- * captured under a root is promoted to its own root row so nothing is hidden.
28
- */
29
- function toTree(nodes) {
30
- const byId = new Map(nodes.map(node => [node.accountId, node]));
31
- const childrenOf = new Map();
32
- for (const node of nodes) {
33
- if (node.parentAccountId && byId.has(node.parentAccountId)) {
34
- const arr = childrenOf.get(node.parentAccountId) ?? [];
35
- arr.push(node);
36
- childrenOf.set(node.parentAccountId, arr);
37
- }
38
- }
39
- const rendered = new Set();
40
- const result = [];
41
- for (const node of nodes) {
42
- const isRoot = !node.parentAccountId || !byId.has(node.parentAccountId);
43
- if (!isRoot) continue;
44
- const children = childrenOf.get(node.accountId) ?? [];
45
- result.push({
46
- root: node,
47
- children
48
- });
49
- rendered.add(node.accountId);
50
- for (const child of children) rendered.add(child.accountId);
51
- }
52
- for (const node of nodes) {
53
- if (!rendered.has(node.accountId)) {
54
- result.push({
55
- root: node,
56
- children: []
57
- });
58
- rendered.add(node.accountId);
59
- }
60
- }
61
- return result;
62
- }
63
-
64
- /**
65
- * The presentational, chrome-agnostic body of the unified account switcher.
66
- *
67
- * Two levels, relationship-aware, both sourced from the single
68
- * {@link useSwitchableAccounts} hook and switched through the SINGLE
69
- * `switchToAccount(accountId)` path:
70
- * - Section A — accounts signed in on THIS device (`onDevice` rows). Tap to
71
- * switch; per-row sign-out; "Add another account".
72
- * - Section B — the account GRAPH not yet signed in here: "Your accounts"
73
- * (self / owned) and "Shared with you" (member). 2-level tree (org →
74
- * children), role badge, search, one-tap to switch.
75
- */
76
- export const AccountSwitcherView = ({
77
- onClose,
78
- onAddAccount,
79
- onNavigateManage,
80
- onCreateAccount,
81
- onOpenAccountSettings,
82
- onBeforeSessionChange
83
- }) => {
84
- const {
85
- switchToAccount,
86
- removeSession,
87
- logout,
88
- logoutAll
89
- } = useOxy();
90
- const {
91
- t
92
- } = useI18n();
93
- const {
94
- colors
95
- } = useTheme();
96
- const {
97
- accounts
98
- } = useSwitchableAccounts();
99
- const [switchingAccountId, setSwitchingAccountId] = useState(null);
100
- const [removingSessionId, setRemovingSessionId] = useState(null);
101
- const [signingOut, setSigningOut] = useState(false);
102
- const [signingOutAll, setSigningOutAll] = useState(false);
103
- const [query, setQuery] = useState('');
104
- const signOutDialog = useDialogControl();
105
- const signOutAllDialog = useDialogControl();
106
-
107
- // Section A — accounts signed in on THIS device, current one first.
108
- const deviceRows = useMemo(() => {
109
- const onDevice = accounts.filter(account => account.onDevice);
110
- const current = onDevice.filter(account => account.isCurrent);
111
- const others = onDevice.filter(account => !account.isCurrent);
112
- return [...current, ...others];
113
- }, [accounts]);
114
-
115
- // Section B — linked graph accounts NOT already signed in on this device.
116
- // (An account switched into becomes a device session, so it moves to Section
117
- // A automatically — the unified hook already deduped it there.)
118
- const graphAccounts = useMemo(() => accounts.filter(account => !account.onDevice), [accounts]);
119
- const isSwitching = switchingAccountId !== null;
120
- const actionDisabled = isSwitching || signingOut || signingOutAll;
121
- const filtered = useMemo(() => {
122
- const q = query.trim().toLowerCase();
123
- if (!q) return graphAccounts;
124
- return graphAccounts.filter(account => {
125
- const name = account.displayName.toLowerCase();
126
- const username = (account.user?.username ?? '').toLowerCase();
127
- return name.includes(q) || username.includes(q);
128
- });
129
- }, [graphAccounts, query]);
130
- const yourAccounts = useMemo(() => toTree(filtered.filter(account => account.relationship !== 'member')), [filtered]);
131
- const sharedAccounts = useMemo(() => toTree(filtered.filter(account => account.relationship === 'member')), [filtered]);
132
-
133
- // The ONE uniform switch path. Device rows AND graph rows both switch by
134
- // account id: `switchToAccount` reuses an existing device session (no mint)
135
- // and mints a real session only on the FIRST entry into a graph account.
136
- const handleSwitch = useCallback(async account => {
137
- if (switchingAccountId) return;
138
- // Tapping the already-active account just closes — it IS the current one.
139
- if (account.isCurrent) {
140
- onClose();
141
- return;
142
- }
143
- setSwitchingAccountId(account.accountId);
144
- try {
145
- await onBeforeSessionChange?.();
146
- await switchToAccount(account.accountId);
147
- toast.success(t('accountSwitcher.toasts.switchSuccess') || 'Switched account');
148
- onClose();
149
- } catch (error) {
150
- if (!isDev()) {
151
- loggerUtil.warn('Switch account failed', {
152
- component: 'AccountSwitcher'
153
- }, error);
154
- }
155
- toast.error(t('accountSwitcher.toasts.switchFailed') || 'Failed to switch account');
156
- } finally {
157
- setSwitchingAccountId(null);
158
- }
159
- }, [switchingAccountId, switchToAccount, t, onClose, onBeforeSessionChange]);
160
- const handleRemoveDevice = useCallback(async sessionId => {
161
- if (removingSessionId) return;
162
- setRemovingSessionId(sessionId);
163
- try {
164
- await removeSession(sessionId);
165
- toast.success(t('common.actions.signedOut') || 'Signed out');
166
- } catch (error) {
167
- loggerUtil.warn('Remove account failed', {
168
- component: 'AccountSwitcher'
169
- }, error);
170
- toast.error(t('common.errors.signOutFailed') || 'Failed to sign out');
171
- } finally {
172
- setRemovingSessionId(null);
173
- }
174
- }, [removingSessionId, removeSession, t]);
175
- const performSignOut = useCallback(async () => {
176
- if (signingOut) return;
177
- setSigningOut(true);
178
- try {
179
- await onBeforeSessionChange?.();
180
- await logout();
181
- toast.success(t('common.actions.signedOut') || 'Signed out');
182
- onClose();
183
- } catch (error) {
184
- loggerUtil.warn('Sign out failed', {
185
- component: 'AccountSwitcher'
186
- }, error);
187
- toast.error(t('common.errors.signOutFailed') || 'Failed to sign out');
188
- } finally {
189
- setSigningOut(false);
190
- }
191
- }, [signingOut, logout, t, onClose, onBeforeSessionChange]);
192
- const performSignOutAll = useCallback(async () => {
193
- if (signingOutAll) return;
194
- setSigningOutAll(true);
195
- try {
196
- await onBeforeSessionChange?.();
197
- await logoutAll();
198
- toast.success(t('accountSwitcher.toasts.signOutAllSuccess') || 'Signed out of all accounts');
199
- onClose();
200
- } catch (error) {
201
- loggerUtil.warn('Sign out all failed', {
202
- component: 'AccountSwitcher'
203
- }, error);
204
- toast.error(t('common.errors.signOutAllFailed') || 'Failed to sign out of all accounts');
205
- } finally {
206
- setSigningOutAll(false);
207
- }
208
- }, [signingOutAll, logoutAll, t, onClose, onBeforeSessionChange]);
209
- const renderAccountNode = useCallback((account, isChild) => {
210
- const displayName = account.displayName;
211
- const secondary = account.email;
212
- const active = account.isCurrent;
213
- const isNodeSwitching = switchingAccountId === account.accountId;
214
- const role = account.callerMembership?.role;
215
- const avatarUri = account.avatarUrl;
216
- const permissions = account.callerMembership?.permissions ?? [];
217
- const canManage = account.relationship !== 'member' || permissions.includes('account:update') || permissions.includes('members:read');
218
- const showSettings = account.relationship !== 'self' && !!onOpenAccountSettings && canManage;
219
- return /*#__PURE__*/_jsxs(TouchableOpacity, {
220
- accessibilityRole: "menuitem",
221
- accessibilityLabel: displayName,
222
- accessibilityState: {
223
- selected: active
224
- },
225
- onPress: () => handleSwitch(account),
226
- disabled: isSwitching,
227
- activeOpacity: 0.6,
228
- style: [styles.accountRow, isChild && styles.childRow, active && {
229
- backgroundColor: colors.primarySubtle
230
- }, isSwitching && !isNodeSwitching && styles.rowDisabled],
231
- children: [/*#__PURE__*/_jsx(Avatar, {
232
- uri: avatarUri,
233
- name: displayName,
234
- size: isChild ? 28 : 34
235
- }), /*#__PURE__*/_jsxs(View, {
236
- style: styles.accountInfo,
237
- children: [/*#__PURE__*/_jsxs(View, {
238
- style: styles.nameRow,
239
- children: [/*#__PURE__*/_jsx(Text, {
240
- style: [styles.accountName, {
241
- color: colors.text
242
- }],
243
- numberOfLines: 1,
244
- children: displayName
245
- }), role ? /*#__PURE__*/_jsx(View, {
246
- style: [styles.roleBadge, {
247
- backgroundColor: colors.card
248
- }],
249
- children: /*#__PURE__*/_jsx(Text, {
250
- style: [styles.roleBadgeText, {
251
- color: colors.textSecondary
252
- }],
253
- children: t(`accounts.roles.${role}.label`) || role
254
- })
255
- }) : null]
256
- }), secondary ? /*#__PURE__*/_jsx(Text, {
257
- style: [styles.accountEmail, {
258
- color: colors.textSecondary
259
- }],
260
- numberOfLines: 1,
261
- children: secondary
262
- }) : null]
263
- }), showSettings ? /*#__PURE__*/_jsx(TouchableOpacity, {
264
- accessibilityRole: "button",
265
- accessibilityLabel: t('accounts.settings.title') || 'Account settings',
266
- onPress: () => onOpenAccountSettings?.(account.accountId),
267
- hitSlop: {
268
- top: 8,
269
- bottom: 8,
270
- left: 8,
271
- right: 8
272
- },
273
- style: styles.settingsButton,
274
- children: /*#__PURE__*/_jsx(Ionicons, {
275
- name: "settings-outline",
276
- size: 16,
277
- color: colors.textSecondary
278
- })
279
- }) : null, isNodeSwitching ? /*#__PURE__*/_jsx(ActivityIndicator, {
280
- color: colors.primary,
281
- size: "small"
282
- }) : active ? /*#__PURE__*/_jsx(Ionicons, {
283
- name: "checkmark",
284
- size: 20,
285
- color: colors.primary
286
- }) : null]
287
- }, `node-${account.accountId}`);
288
- }, [switchingAccountId, isSwitching, colors, handleSwitch, onOpenAccountSettings, t]);
289
- const renderTree = useCallback(entries => entries.map(entry => /*#__PURE__*/_jsxs(View, {
290
- children: [renderAccountNode(entry.root, false), entry.children.map(child => renderAccountNode(child, true))]
291
- }, `tree-${entry.root.accountId}`)), [renderAccountNode]);
292
- return /*#__PURE__*/_jsxs(ScrollView, {
293
- style: styles.scroll,
294
- contentContainerStyle: styles.scrollContent,
295
- showsVerticalScrollIndicator: false,
296
- keyboardShouldPersistTaps: "handled",
297
- children: [/*#__PURE__*/_jsx(Text, {
298
- style: [styles.sectionLabel, {
299
- color: colors.textSecondary
300
- }],
301
- children: t('accountSwitcher.sections.thisDevice') || 'On this device'
302
- }), deviceRows.map(account => {
303
- const sessionId = account.sessionId;
304
- const isBusy = switchingAccountId === account.accountId;
305
- const isRemoving = sessionId ? removingSessionId === sessionId : false;
306
- // The active device session IS the current account — there is no
307
- // separate acting-as concept; switching makes it the whole app.
308
- const isCurrentAccount = account.isCurrent;
309
- return /*#__PURE__*/_jsxs(TouchableOpacity, {
310
- accessibilityRole: "menuitem",
311
- accessibilityLabel: account.displayName,
312
- accessibilityState: {
313
- selected: isCurrentAccount
314
- },
315
- onPress: () => handleSwitch(account),
316
- disabled: isCurrentAccount || isBusy || isSwitching,
317
- activeOpacity: 0.6,
318
- style: [styles.accountRow, isCurrentAccount && {
319
- backgroundColor: colors.primarySubtle
320
- }, isSwitching && !isCurrentAccount && styles.rowDisabled],
321
- children: [/*#__PURE__*/_jsx(Avatar, {
322
- uri: account.avatarUrl,
323
- name: account.displayName,
324
- size: isCurrentAccount ? 40 : 32
325
- }), /*#__PURE__*/_jsxs(View, {
326
- style: styles.accountInfo,
327
- children: [/*#__PURE__*/_jsx(Text, {
328
- style: [styles.accountName, {
329
- color: colors.text
330
- }, isCurrentAccount && styles.accountNameActive],
331
- numberOfLines: 1,
332
- children: account.displayName
333
- }), account.email ? /*#__PURE__*/_jsx(Text, {
334
- style: [styles.accountEmail, {
335
- color: colors.textSecondary
336
- }],
337
- numberOfLines: 1,
338
- children: account.email
339
- }) : null]
340
- }), isBusy ? /*#__PURE__*/_jsx(ActivityIndicator, {
341
- color: colors.primary,
342
- size: "small"
343
- }) : isCurrentAccount ? /*#__PURE__*/_jsx(Ionicons, {
344
- name: "checkmark",
345
- size: 20,
346
- color: colors.primary
347
- }) : isRemoving ? /*#__PURE__*/_jsx(ActivityIndicator, {
348
- color: colors.textSecondary,
349
- size: "small"
350
- }) : sessionId ? /*#__PURE__*/_jsx(TouchableOpacity, {
351
- accessibilityRole: "button",
352
- accessibilityLabel: t('accountMenu.signOutAccount', {
353
- name: account.displayName
354
- }) || `Sign out ${account.displayName}`,
355
- onPress: () => handleRemoveDevice(sessionId),
356
- disabled: isSwitching || removingSessionId !== null,
357
- hitSlop: {
358
- top: 8,
359
- bottom: 8,
360
- left: 8,
361
- right: 8
362
- },
363
- style: styles.settingsButton,
364
- children: /*#__PURE__*/_jsx(Ionicons, {
365
- name: "log-out-outline",
366
- size: 18,
367
- color: colors.textSecondary
368
- })
369
- }) : null]
370
- }, `device-${account.accountId}`);
371
- }), isSwitching ? /*#__PURE__*/_jsxs(View, {
372
- style: styles.switchingRow,
373
- children: [/*#__PURE__*/_jsx(ActivityIndicator, {
374
- color: colors.textSecondary,
375
- size: "small"
376
- }), /*#__PURE__*/_jsx(Text, {
377
- style: [styles.switchingText, {
378
- color: colors.textSecondary
379
- }],
380
- children: t('accountMenu.switching') || 'Switching account…'
381
- })]
382
- }) : null, /*#__PURE__*/_jsxs(TouchableOpacity, {
383
- accessibilityRole: "menuitem",
384
- accessibilityLabel: t('accountMenu.addAnother') || 'Add another account',
385
- onPress: () => {
386
- onClose();
387
- onAddAccount();
388
- },
389
- disabled: actionDisabled,
390
- activeOpacity: 0.6,
391
- style: [styles.actionRow, actionDisabled && styles.rowDisabled],
392
- children: [/*#__PURE__*/_jsx(Ionicons, {
393
- name: "person-add-outline",
394
- size: 20,
395
- color: colors.icon
396
- }), /*#__PURE__*/_jsx(Text, {
397
- style: [styles.actionText, {
398
- color: colors.text
399
- }],
400
- children: t('accountMenu.addAnother') || 'Add another account'
401
- })]
402
- }), graphAccounts.length > 0 ? /*#__PURE__*/_jsxs(_Fragment, {
403
- children: [/*#__PURE__*/_jsx(Divider, {
404
- color: colors.border,
405
- spacing: 4
406
- }), graphAccounts.length > 6 ? /*#__PURE__*/_jsxs(View, {
407
- style: [styles.searchBox, {
408
- backgroundColor: colors.card,
409
- borderColor: colors.border
410
- }],
411
- children: [/*#__PURE__*/_jsx(Ionicons, {
412
- name: "search",
413
- size: 16,
414
- color: colors.textSecondary
415
- }), /*#__PURE__*/_jsx(TextInput, {
416
- value: query,
417
- onChangeText: setQuery,
418
- placeholder: t('accountSwitcher.searchPlaceholder') || 'Search accounts',
419
- placeholderTextColor: colors.textSecondary,
420
- style: [styles.searchInput, {
421
- color: colors.text
422
- }],
423
- autoCapitalize: "none",
424
- autoCorrect: false
425
- })]
426
- }) : null, yourAccounts.length > 0 ? /*#__PURE__*/_jsxs(_Fragment, {
427
- children: [/*#__PURE__*/_jsx(Text, {
428
- style: [styles.sectionLabel, {
429
- color: colors.textSecondary
430
- }],
431
- children: t('accountSwitcher.sections.yourAccounts') || 'Your accounts'
432
- }), renderTree(yourAccounts)]
433
- }) : null, sharedAccounts.length > 0 ? /*#__PURE__*/_jsxs(_Fragment, {
434
- children: [/*#__PURE__*/_jsx(Text, {
435
- style: [styles.sectionLabel, {
436
- color: colors.textSecondary
437
- }],
438
- children: t('accountSwitcher.sections.sharedWithYou') || 'Shared with you'
439
- }), renderTree(sharedAccounts)]
440
- }) : null]
441
- }) : null, /*#__PURE__*/_jsx(Divider, {
442
- color: colors.border,
443
- spacing: 4
444
- }), /*#__PURE__*/_jsxs(TouchableOpacity, {
445
- accessibilityRole: "menuitem",
446
- accessibilityLabel: t('accounts.create.title') || 'Create account',
447
- onPress: () => {
448
- onClose();
449
- onCreateAccount();
450
- },
451
- disabled: actionDisabled,
452
- activeOpacity: 0.6,
453
- style: [styles.actionRow, actionDisabled && styles.rowDisabled],
454
- children: [/*#__PURE__*/_jsx(Ionicons, {
455
- name: "add-circle-outline",
456
- size: 20,
457
- color: colors.icon
458
- }), /*#__PURE__*/_jsx(Text, {
459
- style: [styles.actionText, {
460
- color: colors.text
461
- }],
462
- children: t('accounts.create.title') || 'Create account'
463
- })]
464
- }), /*#__PURE__*/_jsxs(TouchableOpacity, {
465
- accessibilityRole: "menuitem",
466
- accessibilityLabel: t('accountMenu.manage') || 'Manage your Oxy Account',
467
- onPress: () => {
468
- onClose();
469
- onNavigateManage();
470
- },
471
- disabled: actionDisabled,
472
- activeOpacity: 0.6,
473
- style: [styles.actionRow, actionDisabled && styles.rowDisabled],
474
- children: [/*#__PURE__*/_jsx(Ionicons, {
475
- name: "settings-outline",
476
- size: 18,
477
- color: colors.icon
478
- }), /*#__PURE__*/_jsx(Text, {
479
- style: [styles.actionText, {
480
- color: colors.text
481
- }],
482
- children: t('accountMenu.manage') || 'Manage your Oxy Account'
483
- })]
484
- }), /*#__PURE__*/_jsxs(TouchableOpacity, {
485
- accessibilityRole: "menuitem",
486
- accessibilityLabel: t('common.actions.signOut') || 'Sign out',
487
- onPress: () => signOutDialog.open(),
488
- disabled: actionDisabled,
489
- activeOpacity: 0.6,
490
- style: [styles.actionRow, actionDisabled && styles.rowDisabled],
491
- children: [signingOut ? /*#__PURE__*/_jsx(ActivityIndicator, {
492
- color: colors.error,
493
- size: "small"
494
- }) : /*#__PURE__*/_jsx(Ionicons, {
495
- name: "log-out-outline",
496
- size: 18,
497
- color: colors.error
498
- }), /*#__PURE__*/_jsx(Text, {
499
- style: [styles.actionText, {
500
- color: colors.error
501
- }],
502
- children: t('common.actions.signOut') || 'Sign out'
503
- })]
504
- }), deviceRows.length > 1 ? /*#__PURE__*/_jsxs(TouchableOpacity, {
505
- accessibilityRole: "menuitem",
506
- accessibilityLabel: t('accountMenu.signOutAll') || 'Sign out of all accounts',
507
- onPress: () => signOutAllDialog.open(),
508
- disabled: actionDisabled,
509
- activeOpacity: 0.6,
510
- style: [styles.actionRow, actionDisabled && styles.rowDisabled],
511
- children: [signingOutAll ? /*#__PURE__*/_jsx(ActivityIndicator, {
512
- color: colors.error,
513
- size: "small"
514
- }) : /*#__PURE__*/_jsx(Ionicons, {
515
- name: "log-out-outline",
516
- size: 18,
517
- color: colors.error
518
- }), /*#__PURE__*/_jsx(Text, {
519
- style: [styles.actionText, {
520
- color: colors.error
521
- }],
522
- children: t('accountMenu.signOutAll') || 'Sign out of all accounts'
523
- })]
524
- }) : null, /*#__PURE__*/_jsx(Dialog, {
525
- control: signOutDialog,
526
- title: t('common.actions.signOut') || 'Sign out',
527
- description: t('common.confirms.signOut') || 'Are you sure you want to sign out?',
528
- actions: [{
529
- label: t('common.actions.signOut') || 'Sign out',
530
- color: 'destructive',
531
- onPress: performSignOut
532
- }, {
533
- label: t('common.cancel') || 'Cancel',
534
- color: 'cancel'
535
- }]
536
- }), /*#__PURE__*/_jsx(Dialog, {
537
- control: signOutAllDialog,
538
- title: t('accountMenu.signOutAll') || 'Sign out of all accounts',
539
- description: t('common.confirms.signOutAll') || 'Are you sure you want to sign out of all accounts?',
540
- actions: [{
541
- label: t('accountMenu.signOutAll') || 'Sign out of all accounts',
542
- color: 'destructive',
543
- onPress: performSignOutAll
544
- }, {
545
- label: t('common.cancel') || 'Cancel',
546
- color: 'cancel'
547
- }]
548
- })]
549
- });
550
- };
551
- /**
552
- * Unified account switcher presented as a popover (web) / bottom-sheet style
553
- * modal (native). The canonical entry point opened by {@link AccountMenuButton}.
554
- */
555
- const AccountSwitcher = ({
556
- open,
557
- anchor,
558
- ...actions
559
- }) => {
560
- const {
561
- t
562
- } = useI18n();
563
- const {
564
- colors
565
- } = useTheme();
566
- const containerRef = useRef(null);
567
- const {
568
- onClose
569
- } = actions;
570
- useEffect(() => {
571
- if (!open || !isWeb || typeof document === 'undefined') {
572
- return undefined;
573
- }
574
- const onKey = event => {
575
- if (event.key === 'Escape') {
576
- event.stopPropagation();
577
- onClose();
578
- }
579
- };
580
- document.addEventListener('keydown', onKey, true);
581
- return () => document.removeEventListener('keydown', onKey, true);
582
- }, [open, onClose]);
583
- if (!open) {
584
- return null;
585
- }
586
- const anchorStyle = anchor ? {
587
- ...(anchor.top !== undefined ? {
588
- top: anchor.top
589
- } : null),
590
- ...(anchor.bottom !== undefined ? {
591
- bottom: anchor.bottom
592
- } : null),
593
- ...(anchor.left !== undefined ? {
594
- left: anchor.left
595
- } : null),
596
- ...(anchor.right !== undefined ? {
597
- right: anchor.right
598
- } : null)
599
- } : {
600
- top: 64,
601
- right: 16
602
- };
603
- const panelStyles = isWeb ? [styles.panelBase, styles.panelWeb, anchorStyle, {
604
- backgroundColor: colors.background,
605
- borderColor: colors.border
606
- }] : [styles.panelBase, styles.panelNative, {
607
- backgroundColor: colors.background
608
- }];
609
- return /*#__PURE__*/_jsx(Modal, {
610
- visible: open,
611
- transparent: true,
612
- animationType: isWeb ? 'fade' : 'slide',
613
- onRequestClose: actions.onClose,
614
- children: /*#__PURE__*/_jsx(Pressable, {
615
- accessibilityRole: "button",
616
- accessibilityLabel: t('common.actions.close') || 'Close',
617
- onPress: actions.onClose,
618
- style: isWeb ? styles.webOverlay : styles.nativeOverlay,
619
- children: /*#__PURE__*/_jsx(Pressable, {
620
- ref: containerRef,
621
- onPress: () => undefined,
622
- style: panelStyles,
623
- accessibilityRole: "menu",
624
- accessibilityLabel: t('accountSwitcher.label') || 'Account switcher',
625
- children: /*#__PURE__*/_jsx(AccountSwitcherView, {
626
- ...actions
627
- })
628
- })
629
- })
630
- });
631
- };
632
- const styles = StyleSheet.create({
633
- webOverlay: {
634
- flex: 1,
635
- backgroundColor: 'transparent',
636
- position: 'relative'
637
- },
638
- nativeOverlay: {
639
- flex: 1,
640
- backgroundColor: 'rgba(0,0,0,0.32)',
641
- justifyContent: 'flex-end'
642
- },
643
- panelBase: {
644
- borderRadius: 12,
645
- shadowColor: '#000',
646
- shadowOpacity: 0.18,
647
- shadowRadius: 24,
648
- shadowOffset: {
649
- width: 0,
650
- height: 8
651
- },
652
- elevation: 12,
653
- overflow: 'hidden'
654
- },
655
- panelWeb: {
656
- position: 'absolute',
657
- width: PANEL_WIDTH,
658
- maxHeight: '85%',
659
- borderWidth: 1
660
- },
661
- panelNative: {
662
- marginHorizontal: 0,
663
- borderTopLeftRadius: 20,
664
- borderTopRightRadius: 20,
665
- paddingBottom: 12,
666
- maxHeight: '85%'
667
- },
668
- scroll: {
669
- flexGrow: 0
670
- },
671
- scrollContent: {
672
- paddingVertical: 4
673
- },
674
- sectionLabel: {
675
- fontSize: 11,
676
- fontWeight: '600',
677
- textTransform: 'uppercase',
678
- letterSpacing: 0.5,
679
- paddingHorizontal: 14,
680
- paddingTop: 12,
681
- paddingBottom: 4
682
- },
683
- accountRow: {
684
- flexDirection: 'row',
685
- alignItems: 'center',
686
- paddingHorizontal: 14,
687
- paddingVertical: 10,
688
- gap: 10
689
- },
690
- childRow: {
691
- paddingLeft: 34
692
- },
693
- rowDisabled: {
694
- opacity: 0.4
695
- },
696
- accountInfo: {
697
- flex: 1,
698
- minWidth: 0
699
- },
700
- nameRow: {
701
- flexDirection: 'row',
702
- alignItems: 'center',
703
- gap: 6
704
- },
705
- accountName: {
706
- fontSize: 13,
707
- fontWeight: '500',
708
- flexShrink: 1
709
- },
710
- accountNameActive: {
711
- fontWeight: '600'
712
- },
713
- accountEmail: {
714
- fontSize: 11,
715
- marginTop: 1
716
- },
717
- roleBadge: {
718
- paddingHorizontal: 6,
719
- paddingVertical: 1,
720
- borderRadius: 8
721
- },
722
- roleBadgeText: {
723
- fontSize: 10,
724
- fontWeight: '600',
725
- textTransform: 'capitalize'
726
- },
727
- settingsButton: {
728
- width: 28,
729
- height: 28,
730
- alignItems: 'center',
731
- justifyContent: 'center',
732
- borderRadius: 14
733
- },
734
- switchingRow: {
735
- flexDirection: 'row',
736
- alignItems: 'center',
737
- justifyContent: 'center',
738
- paddingVertical: 8,
739
- gap: 8
740
- },
741
- switchingText: {
742
- fontSize: 12,
743
- fontWeight: '500'
744
- },
745
- searchBox: {
746
- flexDirection: 'row',
747
- alignItems: 'center',
748
- gap: 8,
749
- marginHorizontal: 14,
750
- marginVertical: 6,
751
- paddingHorizontal: 10,
752
- height: 36,
753
- borderRadius: 10,
754
- borderWidth: 1
755
- },
756
- searchInput: {
757
- flex: 1,
758
- fontSize: 13,
759
- padding: 0
760
- },
761
- actionRow: {
762
- flexDirection: 'row',
763
- alignItems: 'center',
764
- paddingHorizontal: 14,
765
- paddingVertical: 12,
766
- gap: 10
767
- },
768
- actionText: {
769
- fontSize: 13,
770
- fontWeight: '500'
771
- }
772
- });
773
- export default AccountSwitcher;
774
- //# sourceMappingURL=AccountSwitcher.js.map