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