@oxyhq/services 13.0.3 → 13.1.1
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 +18 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/components/ProfileButton.js +233 -0
- package/lib/commonjs/ui/components/ProfileButton.js.map +1 -0
- package/lib/commonjs/ui/components/ProfileMenu.js +374 -0
- package/lib/commonjs/ui/components/ProfileMenu.js.map +1 -0
- package/lib/commonjs/ui/components/SettingsIcon.js.map +1 -1
- package/lib/commonjs/ui/components/fileManagement/FileViewer.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +64 -11
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +28 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/index.js +14 -0
- package/lib/commonjs/ui/index.js.map +1 -1
- package/lib/commonjs/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/commonjs/ui/utils/activeAuthuser.js +47 -0
- package/lib/commonjs/ui/utils/activeAuthuser.js.map +1 -1
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/components/ProfileButton.js +228 -0
- package/lib/module/ui/components/ProfileButton.js.map +1 -0
- package/lib/module/ui/components/ProfileMenu.js +370 -0
- package/lib/module/ui/components/ProfileMenu.js.map +1 -0
- package/lib/module/ui/components/SettingsIcon.js.map +1 -1
- package/lib/module/ui/components/fileManagement/FileViewer.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +65 -12
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +29 -2
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/index.js +2 -0
- package/lib/module/ui/index.js.map +1 -1
- package/lib/module/ui/screens/FeedbackScreen.js.map +1 -1
- package/lib/module/ui/utils/activeAuthuser.js +45 -1
- package/lib/module/ui/utils/activeAuthuser.js.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +4 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/ProfileButton.d.ts +46 -0
- package/lib/typescript/commonjs/ui/components/ProfileButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/ProfileMenu.d.ts +39 -0
- package/lib/typescript/commonjs/ui/components/ProfileMenu.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/SettingsIcon.d.ts +2 -1
- package/lib/typescript/commonjs/ui/components/SettingsIcon.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/payment/types.d.ts +3 -1
- package/lib/typescript/commonjs/ui/components/payment/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/index.d.ts +2 -0
- package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/activeAuthuser.d.ts +24 -0
- package/lib/typescript/commonjs/ui/utils/activeAuthuser.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +4 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/ProfileButton.d.ts +46 -0
- package/lib/typescript/module/ui/components/ProfileButton.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/ProfileMenu.d.ts +39 -0
- package/lib/typescript/module/ui/components/ProfileMenu.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/SettingsIcon.d.ts +2 -1
- package/lib/typescript/module/ui/components/SettingsIcon.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/payment/types.d.ts +3 -1
- package/lib/typescript/module/ui/components/payment/types.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/module/ui/index.d.ts +2 -0
- package/lib/typescript/module/ui/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/activeAuthuser.d.ts +24 -0
- package/lib/typescript/module/ui/utils/activeAuthuser.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/index.ts +8 -0
- package/src/ui/components/ProfileButton.tsx +270 -0
- package/src/ui/components/ProfileMenu.tsx +416 -0
- package/src/ui/components/SettingsIcon.tsx +2 -2
- package/src/ui/components/fileManagement/FileViewer.tsx +1 -1
- package/src/ui/components/payment/types.ts +3 -1
- package/src/ui/context/OxyContext.tsx +65 -11
- package/src/ui/context/hooks/useAuthOperations.ts +35 -2
- package/src/ui/index.ts +2 -0
- package/src/ui/screens/FeedbackScreen.tsx +3 -3
- package/src/ui/utils/activeAuthuser.ts +46 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_core","require","ACTIVE_AUTHUSER_KEY","exports","hasLocalStorage","window","localStorage","getSessionStorage","sessionStorage","readActiveAuthuser","raw","getItem","parsed","Number","parseInt","isFinite","writeActiveAuthuser","authuser","setItem","String","clearActiveAuthuser","removeItem","
|
|
1
|
+
{"version":3,"names":["_core","require","ACTIVE_AUTHUSER_KEY","exports","hasLocalStorage","window","localStorage","getSessionStorage","sessionStorage","readActiveAuthuser","raw","getItem","parsed","Number","parseInt","isFinite","writeActiveAuthuser","authuser","setItem","String","clearActiveAuthuser","removeItem","markSignedOut","ssoSignedOutKey","location","origin","clearSignedOut","isSilentRestoreSuppressed","silentRestoreSuppressed","clearSsoBounceState","storage","ssoAttemptedKey","ssoNoSessionKey","ssoGuardKey","ssoStateKey","ssoDestKey"],"sourceRoot":"../../../../src","sources":["ui/utils/activeAuthuser.ts"],"mappings":";;;;;;;;;;;;;AAoBA,IAAAA,KAAA,GAAAC,OAAA;AApBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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QAAQ,CAACC,MAAM;IACrCK,OAAO,CAACT,UAAU,CAAC,IAAAU,qBAAe,EAACN,MAAM,CAAC,CAAC;IAC3CK,OAAO,CAACT,UAAU,CAAC,IAAAW,qBAAe,EAACP,MAAM,CAAC,CAAC;IAC3CK,OAAO,CAACT,UAAU,CAAC,IAAAY,iBAAW,EAACR,MAAM,CAAC,CAAC;IACvCK,OAAO,CAACT,UAAU,CAAC,IAAAa,iBAAW,EAACT,MAAM,CAAC,CAAC;IACvCK,OAAO,CAACT,UAAU,CAAC,IAAAc,gBAAU,EAACV,MAAM,CAAC,CAAC;EACxC,CAAC,CAAC,MAAM;IACN;EAAA;AAEJ","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -112,6 +112,11 @@ export { LogoText } from "./ui/components/logo/LogoText.js";
|
|
|
112
112
|
// Unified account menu (device-only switcher — popover on web, sheet on native)
|
|
113
113
|
export { default as AccountMenu } from "./ui/components/AccountMenu.js";
|
|
114
114
|
export { default as AccountMenuButton } from "./ui/components/AccountMenuButton.js";
|
|
115
|
+
// Sidebar account button + its device-account switcher menu (Bluesky-style
|
|
116
|
+
// ProfileCard). `ProfileButton` owns its own open state + anchor measurement
|
|
117
|
+
// and opens `ProfileMenu` upward from a sidebar footer.
|
|
118
|
+
export { default as ProfileButton } from "./ui/components/ProfileButton.js";
|
|
119
|
+
export { default as ProfileMenu } from "./ui/components/ProfileMenu.js";
|
|
115
120
|
// Unified account switcher (device sign-ins + account graph). `AccountMenuButton`
|
|
116
121
|
// opens this; the `AccountSwitcherView` body also backs the `AccountSwitcher`
|
|
117
122
|
// bottom-sheet route.
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["setPlatformOS","Platform","OS","default","OxyProvider","useOxy","useAuth","FontLoader","useAuthStore","useAssetStore","useAssets","useAssetsStore","useAsset","useUploadProgress","useAssetLoading","useAssetErrors","useAssetsByApp","useAssetsByEntity","useAssetUsageCount","useIsAssetLinked","useSessionSocket","setOxyAssetInstance","useFileDownloadUrl","useFollow","useFollowerCounts","useUserProfile","useUserProfiles","useCurrentUser","useUserById","useUserByUsername","useUsersBySessions","usePrivacySettings","useAuthorizedApps","useSessions","useSession","useDeviceSessions","useUserDevices","useSecurityInfo","useAccountStorageUsage","useSecurityActivity","useRecentSecurityActivity","useInfiniteSecurityActivity","useUserSubscription","useUserPayments","useUserWallet","useUserWalletTransactions","useUpdateProfile","useUploadAvatar","useUpdateAccountSettings","useUpdatePrivacySettings","useUpdateNotificationPreferences","useUpdateUserPreferences","useRevokeAuthorizedApp","useUploadFile","useSwitchSession","useLogoutSession","useLogoutAll","useUpdateDeviceName","useRemoveDevice","createProfileMutation","createGenericMutation","mutationKeys","queryKeys","invalidateAccountQueries","invalidateUserQueries","invalidateSessionQueries","invalidateDeviceQueries","invalidatePrivacyQueries","invalidateSecurityQueries","invalidateStorageQueries","invalidatePaymentsQueries","invalidateConnectedAppsQueries","useMutationStatus","useOnlineStatus","handleAuthError","isInvalidSessionError","isTimeoutOrNetworkError","extractErrorMessage","CrossApexDirectSignInError","isCrossApexWeb","useFileFiltering","Avatar","OxySignInButton","OxyAuthPrompt","OxyLogo","FollowButton","LogoIcon","LogoText","AccountMenu","AccountMenuButton","AccountSwitcher","AccountSwitcherView","useDeviceAccounts","ManageAccountScreen","NotificationsScreen","PreferencesScreen","ConnectedAppsScreen","AccountSwitcherScreen","CreateAccountScreen","AccountMembersScreen","AccountSettingsScreen","showBottomSheet","closeBottomSheet","showSignInModal","hideSignInModal"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,SAASA,aAAa,QAAyB,aAAa;AAC5D,SAASC,QAAQ,QAAQ,cAAc;AACvCD,aAAa,CAACC,QAAQ,CAACC,EAAgB,CAAC;;AAExC;AACA;AACA;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B,EACrBC,qBAAqB,QAClB,yCAAsC;AAM7C;AACA,SAASC,YAAY,QAAQ,sCAAmC;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA,SACIC,SAAS,EACTC,wBAAwB,EACxBC,qBAAqB,EACrBC,wBAAwB,EACxBC,uBAAuB,EACvBC,wBAAwB,EACxBC,yBAAyB,EACzBC,wBAAwB,EACxBC,yBAAyB,EACzBC,8BAA8B,QAC3B,iCAA8B;;AAErC;AACA,SAASC,iBAAiB,QAAQ,iCAA8B;AAEhE,SAASC,eAAe,QAAQ,+BAA4B;;AAE5D;AACA;AACA;AACA,SACIC,eAAe,EACfC,qBAAqB,EACrBC,uBAAuB,EACvBC,mBAAmB,QAChB,6BAA0B;AAEjC;AACA;AACA;AACA,SAASC,0BAA0B,EAAEC,cAAc,QAAQ,sBAAmB;;AAE9E;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,gCAA6B;AAG9D;AACA;AACA;AACA,SAAS7E,OAAO,IAAI8E,MAAM,QAAQ,2BAAwB;AAE1D,SAASC,eAAe,QAAQ,oCAAiC;AACjE,SAASC,aAAa,QAAQ,kCAA+B;AAE7D,SAAShF,OAAO,IAAIiF,OAAO,QAAQ,4BAAyB;AAC5D,SAASjF,OAAO,IAAIkF,YAAY,QAAQ,iCAA8B;AAEtE,SAASC,QAAQ,QAAQ,kCAA+B;AACxD,SAASC,QAAQ,QAAQ,kCAA+B;;AAExD;AACA,SAASpF,OAAO,IAAIqF,WAAW,QAAQ,gCAA6B;AAEpE,SAASrF,OAAO,IAAIsF,iBAAiB,QAAQ,sCAAmC;AAGhF;AACA;AACA;AACA,SAAStF,OAAO,IAAIuF,eAAe,EAAEC,mBAAmB,QAAQ,oCAAiC;AAGjG;AACA;AACA,SAASC,iBAAiB,QAAQ,iCAA8B;AAOhE;AACA,
|
|
1
|
+
{"version":3,"names":["setPlatformOS","Platform","OS","default","OxyProvider","useOxy","useAuth","FontLoader","useAuthStore","useAssetStore","useAssets","useAssetsStore","useAsset","useUploadProgress","useAssetLoading","useAssetErrors","useAssetsByApp","useAssetsByEntity","useAssetUsageCount","useIsAssetLinked","useSessionSocket","setOxyAssetInstance","useFileDownloadUrl","useFollow","useFollowerCounts","useUserProfile","useUserProfiles","useCurrentUser","useUserById","useUserByUsername","useUsersBySessions","usePrivacySettings","useAuthorizedApps","useSessions","useSession","useDeviceSessions","useUserDevices","useSecurityInfo","useAccountStorageUsage","useSecurityActivity","useRecentSecurityActivity","useInfiniteSecurityActivity","useUserSubscription","useUserPayments","useUserWallet","useUserWalletTransactions","useUpdateProfile","useUploadAvatar","useUpdateAccountSettings","useUpdatePrivacySettings","useUpdateNotificationPreferences","useUpdateUserPreferences","useRevokeAuthorizedApp","useUploadFile","useSwitchSession","useLogoutSession","useLogoutAll","useUpdateDeviceName","useRemoveDevice","createProfileMutation","createGenericMutation","mutationKeys","queryKeys","invalidateAccountQueries","invalidateUserQueries","invalidateSessionQueries","invalidateDeviceQueries","invalidatePrivacyQueries","invalidateSecurityQueries","invalidateStorageQueries","invalidatePaymentsQueries","invalidateConnectedAppsQueries","useMutationStatus","useOnlineStatus","handleAuthError","isInvalidSessionError","isTimeoutOrNetworkError","extractErrorMessage","CrossApexDirectSignInError","isCrossApexWeb","useFileFiltering","Avatar","OxySignInButton","OxyAuthPrompt","OxyLogo","FollowButton","LogoIcon","LogoText","AccountMenu","AccountMenuButton","ProfileButton","ProfileMenu","AccountSwitcher","AccountSwitcherView","useDeviceAccounts","ManageAccountScreen","NotificationsScreen","PreferencesScreen","ConnectedAppsScreen","AccountSwitcherScreen","CreateAccountScreen","AccountMembersScreen","AccountSettingsScreen","showBottomSheet","closeBottomSheet","showSignInModal","hideSignInModal"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA,SAASA,aAAa,QAAyB,aAAa;AAC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eAAe,EAAEC,mBAAmB,QAAQ,oCAAiC;AAGjG;AACA;AACA,SAASC,iBAAiB,QAAQ,iCAA8B;AAOhE;AACA,SAAS3F,OAAO,IAAI4F,mBAAmB,QAAQ,qCAAkC;AACjF,SAAS5F,OAAO,IAAI6F,mBAAmB,QAAQ,qCAAkC;AACjF,SAAS7F,OAAO,IAAI8F,iBAAiB,QAAQ,mCAAgC;AAC7E,SAAS9F,OAAO,IAAI+F,mBAAmB,QAAQ,qCAAkC;;AAEjF;AACA,SAAS/F,OAAO,IAAIgG,qBAAqB,QAAQ,uCAAoC;AACrF,SAAShG,OAAO,IAAIiG,mBAAmB,QAAQ,qCAAkC;AACjF,SAASjG,OAAO,IAAIkG,oBAAoB,QAAQ,sCAAmC;AACnF,SAASlG,OAAO,IAAImG,qBAAqB,QAAQ,uCAAoC;;AAErF;AACA;AACA;AACA,SAASC,eAAe,EAAEC,gBAAgB,QAAQ,uCAAoC;AAGtF;AACA;AACA;AACA,SAASC,eAAe,EAAEC,eAAe,QAAQ,gCAA6B","ignoreList":[]}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useRef, useState } from 'react';
|
|
4
|
+
import { View, Pressable, Platform } from 'react-native';
|
|
5
|
+
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
|
6
|
+
import { Avatar } from '@oxyhq/bloom/avatar';
|
|
7
|
+
import { Text } from '@oxyhq/bloom/typography';
|
|
8
|
+
import { useTheme } from '@oxyhq/bloom/theme';
|
|
9
|
+
import { getAccountDisplayName, getAccountFallbackHandle } from '@oxyhq/core';
|
|
10
|
+
import { useAuth } from "../hooks/useAuth.js";
|
|
11
|
+
import { useI18n } from "../hooks/useI18n.js";
|
|
12
|
+
import ProfileMenu from "./ProfileMenu.js";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
const isWeb = Platform.OS === 'web';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Fixed popover width used by {@link ProfileMenu} on web. `ProfileButton`
|
|
18
|
+
* mirrors this constant when computing the trigger-relative anchor so the
|
|
19
|
+
* left-edge clamp keeps the panel fully on-screen. Keep the two in sync.
|
|
20
|
+
*/
|
|
21
|
+
const MENU_WIDTH = 300;
|
|
22
|
+
|
|
23
|
+
/** Gutter, in px, kept between the popover and the viewport edges on web. */
|
|
24
|
+
const VIEWPORT_GUTTER = 8;
|
|
25
|
+
/**
|
|
26
|
+
* Self-contained sidebar account trigger, modeled on Bluesky's ProfileCard and
|
|
27
|
+
* the Oxy inbox's `MailboxDrawer` footer. Owns its own open state + anchor
|
|
28
|
+
* measurement, and renders {@link ProfileMenu} (the device-account switcher).
|
|
29
|
+
*
|
|
30
|
+
* Three auth states from {@link useAuth}:
|
|
31
|
+
* - **Undetermined** (`!isAuthResolved || isPrivateApiPending`): a neutral
|
|
32
|
+
* avatar-sized skeleton circle, no press.
|
|
33
|
+
* - **Signed in**: a pressable row — Bloom `Avatar` + display name + `@handle`
|
|
34
|
+
* + an `unfold-more-horizontal` chevron. Press opens the menu upward (web)
|
|
35
|
+
* against the measured trigger, or as a bottom sheet (native).
|
|
36
|
+
* - **Signed out**: a "Sign in" row that calls `useAuth().signIn()`.
|
|
37
|
+
*
|
|
38
|
+
* All display strings resolve through `@oxyhq/core`'s
|
|
39
|
+
* `getAccountDisplayName` / `getAccountFallbackHandle` — no hand-rolled name
|
|
40
|
+
* fallbacks. Avatars pass the bare file id as `source` + `variant="thumb"`, so
|
|
41
|
+
* the app's registered `ImageResolver` builds the thumbnail URL.
|
|
42
|
+
*/
|
|
43
|
+
const ProfileButton = ({
|
|
44
|
+
expanded = true,
|
|
45
|
+
avatarSize,
|
|
46
|
+
onNavigateManage,
|
|
47
|
+
onAddAccount,
|
|
48
|
+
onNavigateProfile,
|
|
49
|
+
onBeforeSessionChange,
|
|
50
|
+
className,
|
|
51
|
+
style
|
|
52
|
+
}) => {
|
|
53
|
+
const {
|
|
54
|
+
user,
|
|
55
|
+
isAuthenticated,
|
|
56
|
+
isAuthResolved,
|
|
57
|
+
isPrivateApiPending,
|
|
58
|
+
signIn
|
|
59
|
+
} = useAuth();
|
|
60
|
+
const {
|
|
61
|
+
colors
|
|
62
|
+
} = useTheme();
|
|
63
|
+
const {
|
|
64
|
+
t,
|
|
65
|
+
locale
|
|
66
|
+
} = useI18n();
|
|
67
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
68
|
+
const [anchor, setAnchor] = useState(null);
|
|
69
|
+
|
|
70
|
+
// Trigger ref for the web anchor measurement. RN-Web exposes `measure()` on
|
|
71
|
+
// host views, so we anchor the popover to the button rect and open upward.
|
|
72
|
+
const triggerRef = useRef(null);
|
|
73
|
+
const resolvedAvatarSize = avatarSize ?? (expanded ? 40 : 32);
|
|
74
|
+
const openMenu = useCallback(() => {
|
|
75
|
+
if (!isWeb) {
|
|
76
|
+
setAnchor(null);
|
|
77
|
+
setMenuOpen(true);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const node = triggerRef.current;
|
|
81
|
+
if (!node || typeof node.measure !== 'function' || typeof window === 'undefined') {
|
|
82
|
+
setAnchor(null);
|
|
83
|
+
setMenuOpen(true);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
node.measure((_x, _y, _w, _h, pageX, pageY) => {
|
|
87
|
+
if (typeof pageX !== 'number' || typeof pageY !== 'number') {
|
|
88
|
+
setAnchor(null);
|
|
89
|
+
} else {
|
|
90
|
+
// Clamp the panel's left edge inside the viewport gutter.
|
|
91
|
+
const maxLeft = Math.max(VIEWPORT_GUTTER, window.innerWidth - MENU_WIDTH - VIEWPORT_GUTTER);
|
|
92
|
+
const left = Math.min(Math.max(VIEWPORT_GUTTER, pageX), maxLeft);
|
|
93
|
+
// Anchor the panel's BOTTOM edge just above the trigger top so
|
|
94
|
+
// the menu opens upward from this footer button.
|
|
95
|
+
const bottom = Math.max(VIEWPORT_GUTTER, window.innerHeight - pageY + VIEWPORT_GUTTER);
|
|
96
|
+
setAnchor({
|
|
97
|
+
left,
|
|
98
|
+
bottom
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
setMenuOpen(true);
|
|
102
|
+
});
|
|
103
|
+
}, []);
|
|
104
|
+
const handleClose = useCallback(() => {
|
|
105
|
+
setMenuOpen(false);
|
|
106
|
+
}, []);
|
|
107
|
+
|
|
108
|
+
// ── Undetermined: skeleton circle, no interaction. ──────────────────────
|
|
109
|
+
if (!isAuthResolved || isPrivateApiPending) {
|
|
110
|
+
return /*#__PURE__*/_jsx(View, {
|
|
111
|
+
className: className,
|
|
112
|
+
style: style,
|
|
113
|
+
accessibilityElementsHidden: true,
|
|
114
|
+
importantForAccessibility: "no-hide-descendants",
|
|
115
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
116
|
+
className: "rounded-full bg-secondary",
|
|
117
|
+
style: {
|
|
118
|
+
width: resolvedAvatarSize,
|
|
119
|
+
height: resolvedAvatarSize
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ── Signed out: "Sign in" row. ──────────────────────────────────────────
|
|
126
|
+
if (!isAuthenticated || !user) {
|
|
127
|
+
const signInLabel = t('common.actions.signIn') || 'Sign in';
|
|
128
|
+
return /*#__PURE__*/_jsxs(Pressable, {
|
|
129
|
+
className: `flex-row items-center gap-3 rounded-full px-2 py-2 ${className ?? ''}`,
|
|
130
|
+
style: style,
|
|
131
|
+
onPress: () => {
|
|
132
|
+
void signIn();
|
|
133
|
+
},
|
|
134
|
+
accessibilityRole: "button",
|
|
135
|
+
accessibilityLabel: signInLabel,
|
|
136
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
137
|
+
className: "items-center justify-center rounded-full bg-secondary",
|
|
138
|
+
style: {
|
|
139
|
+
width: resolvedAvatarSize,
|
|
140
|
+
height: resolvedAvatarSize
|
|
141
|
+
},
|
|
142
|
+
children: /*#__PURE__*/_jsx(MaterialCommunityIcons, {
|
|
143
|
+
name: "login",
|
|
144
|
+
size: Math.round(resolvedAvatarSize * 0.5),
|
|
145
|
+
color: colors.icon
|
|
146
|
+
})
|
|
147
|
+
}), expanded ? /*#__PURE__*/_jsx(Text, {
|
|
148
|
+
className: "flex-1 font-semibold text-foreground",
|
|
149
|
+
numberOfLines: 1,
|
|
150
|
+
children: signInLabel
|
|
151
|
+
}) : null]
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// ── Signed in: avatar + identity + chevron. ─────────────────────────────
|
|
156
|
+
const displayName = getAccountDisplayName(user, locale);
|
|
157
|
+
const handle = getAccountFallbackHandle(user);
|
|
158
|
+
const handleLine = handle ? `@${handle}` : null;
|
|
159
|
+
const avatarNode = /*#__PURE__*/_jsx(Avatar, {
|
|
160
|
+
source: user.avatar ?? undefined,
|
|
161
|
+
variant: "thumb",
|
|
162
|
+
name: displayName,
|
|
163
|
+
size: resolvedAvatarSize
|
|
164
|
+
});
|
|
165
|
+
if (!expanded) {
|
|
166
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
167
|
+
className: className,
|
|
168
|
+
style: style,
|
|
169
|
+
children: [/*#__PURE__*/_jsx(Pressable, {
|
|
170
|
+
ref: triggerRef,
|
|
171
|
+
className: "rounded-full",
|
|
172
|
+
onPress: openMenu,
|
|
173
|
+
accessibilityRole: "button",
|
|
174
|
+
accessibilityLabel: t('accountSwitcher.switchWhileSignedInAs', {
|
|
175
|
+
name: displayName
|
|
176
|
+
}) || `Switch account, signed in as ${displayName}`,
|
|
177
|
+
children: avatarNode
|
|
178
|
+
}), /*#__PURE__*/_jsx(ProfileMenu, {
|
|
179
|
+
open: menuOpen,
|
|
180
|
+
onClose: handleClose,
|
|
181
|
+
anchor: anchor,
|
|
182
|
+
onNavigateManage: onNavigateManage,
|
|
183
|
+
onAddAccount: onAddAccount,
|
|
184
|
+
onNavigateProfile: onNavigateProfile,
|
|
185
|
+
onBeforeSessionChange: onBeforeSessionChange
|
|
186
|
+
})]
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
190
|
+
className: className,
|
|
191
|
+
style: style,
|
|
192
|
+
children: [/*#__PURE__*/_jsxs(Pressable, {
|
|
193
|
+
ref: triggerRef,
|
|
194
|
+
className: "flex-row items-center gap-3 rounded-full px-2 py-2",
|
|
195
|
+
onPress: openMenu,
|
|
196
|
+
accessibilityRole: "button",
|
|
197
|
+
accessibilityLabel: t('accountSwitcher.switchWhileSignedInAs', {
|
|
198
|
+
name: displayName
|
|
199
|
+
}) || `Switch account, signed in as ${displayName}`,
|
|
200
|
+
children: [avatarNode, /*#__PURE__*/_jsxs(View, {
|
|
201
|
+
className: "min-w-0 flex-1",
|
|
202
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
203
|
+
className: "font-bold text-foreground",
|
|
204
|
+
numberOfLines: 1,
|
|
205
|
+
children: displayName
|
|
206
|
+
}), handleLine ? /*#__PURE__*/_jsx(Text, {
|
|
207
|
+
className: "text-xs text-muted-foreground",
|
|
208
|
+
numberOfLines: 1,
|
|
209
|
+
children: handleLine
|
|
210
|
+
}) : null]
|
|
211
|
+
}), /*#__PURE__*/_jsx(MaterialCommunityIcons, {
|
|
212
|
+
name: "unfold-more-horizontal",
|
|
213
|
+
size: 18,
|
|
214
|
+
color: colors.textSecondary
|
|
215
|
+
})]
|
|
216
|
+
}), /*#__PURE__*/_jsx(ProfileMenu, {
|
|
217
|
+
open: menuOpen,
|
|
218
|
+
onClose: handleClose,
|
|
219
|
+
anchor: anchor,
|
|
220
|
+
onNavigateManage: onNavigateManage,
|
|
221
|
+
onAddAccount: onAddAccount,
|
|
222
|
+
onNavigateProfile: onNavigateProfile,
|
|
223
|
+
onBeforeSessionChange: onBeforeSessionChange
|
|
224
|
+
})]
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
export default ProfileButton;
|
|
228
|
+
//# sourceMappingURL=ProfileButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","useState","View","Pressable","Platform","MaterialCommunityIcons","Avatar","Text","useTheme","getAccountDisplayName","getAccountFallbackHandle","useAuth","useI18n","ProfileMenu","jsx","_jsx","jsxs","_jsxs","isWeb","OS","MENU_WIDTH","VIEWPORT_GUTTER","ProfileButton","expanded","avatarSize","onNavigateManage","onAddAccount","onNavigateProfile","onBeforeSessionChange","className","style","user","isAuthenticated","isAuthResolved","isPrivateApiPending","signIn","colors","t","locale","menuOpen","setMenuOpen","anchor","setAnchor","triggerRef","resolvedAvatarSize","openMenu","node","current","measure","window","_x","_y","_w","_h","pageX","pageY","maxLeft","Math","max","innerWidth","left","min","bottom","innerHeight","handleClose","accessibilityElementsHidden","importantForAccessibility","children","width","height","signInLabel","onPress","accessibilityRole","accessibilityLabel","name","size","round","color","icon","numberOfLines","displayName","handle","handleLine","avatarNode","source","avatar","undefined","variant","ref","open","onClose","textSecondary"],"sourceRoot":"../../../../src","sources":["ui/components/ProfileButton.tsx"],"mappings":";;AACA,SAASA,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACrD,SACIC,IAAI,EACJC,SAAS,EACTC,QAAQ,QAGL,cAAc;AACrB,SAASC,sBAAsB,QAAQ,oBAAoB;AAC3D,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,IAAI,QAAQ,yBAAyB;AAC9C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,qBAAqB,EAAEC,wBAAwB,QAAQ,aAAa;AAC7E,SAASC,OAAO,QAAQ,qBAAkB;AAC1C,SAASC,OAAO,QAAQ,qBAAkB;AAC1C,OAAOC,WAAW,MAAkC,kBAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEpE,MAAMC,KAAK,GAAGd,QAAQ,CAACe,EAAE,KAAK,KAAK;;AAEnC;AACA;AACA;AACA;AACA;AACA,MAAMC,U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gBAC5BpD,IAAA,CAACR,IAAI;UAACsB,SAAS,EAAC,2BAA2B;UAACkD,aAAa,EAAE,CAAE;UAAAZ,QAAA,EACxDa;QAAW,CACV,CAAC,EACNE,UAAU,gBACPnE,IAAA,CAACR,IAAI;UAACsB,SAAS,EAAC,+BAA+B;UAACkD,aAAa,EAAE,CAAE;UAAAZ,QAAA,EAC5De;QAAU,CACT,CAAC,GACP,IAAI;MAAA,CACN,CAAC,eACPnE,IAAA,CAACV,sBAAsB;QACnBqE,IAAI,EAAC,wBAAwB;QAC7BC,IAAI,EAAE,EAAG;QACTE,KAAK,EAAEzC,MAAM,CAACuD;MAAc,CAC/B,CAAC;IAAA,CACK,CAAC,eACZ5E,IAAA,CAACF,WAAW;MACR4E,IAAI,EAAElD,QAAS;MACfmD,OAAO,EAAE1B,WAAY;MACrBvB,MAAM,EAAEA,MAAO;MACfhB,gBAAgB,EAAEA,gBAAiB;MACnCC,YAAY,EAAEA,YAAa;MAC3BC,iBAAiB,EAAEA,iBAAkB;MACrCC,qBAAqB,EAAEA;IAAsB,CAChD,CAAC;EAAA,CACA,CAAC;AAEf,CAAC;AAED,eAAeN,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import { View, Pressable, Modal, ScrollView, ActivityIndicator, Platform } from 'react-native';
|
|
5
|
+
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
|
6
|
+
import { Avatar } from '@oxyhq/bloom/avatar';
|
|
7
|
+
import { Text } from '@oxyhq/bloom/typography';
|
|
8
|
+
import { useTheme } from '@oxyhq/bloom/theme';
|
|
9
|
+
import { toast, useDialogControl, Dialog } from '@oxyhq/bloom';
|
|
10
|
+
import { Divider } from '@oxyhq/bloom/divider';
|
|
11
|
+
import { isDev, logger as loggerUtil } from '@oxyhq/core';
|
|
12
|
+
import { useOxy } from "../context/OxyContext.js";
|
|
13
|
+
import { useI18n } from "../hooks/useI18n.js";
|
|
14
|
+
import { useDeviceAccounts } from "../hooks/useDeviceAccounts.js";
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
const isWeb = Platform.OS === 'web';
|
|
17
|
+
|
|
18
|
+
/** Fixed popover width on web. `ProfileButton` mirrors this when anchoring. */
|
|
19
|
+
const MENU_WIDTH = 300;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Web-only anchor. `ProfileButton` measures its trigger and anchors the panel's
|
|
23
|
+
* BOTTOM-LEFT corner so the menu opens UPWARD from the sidebar footer. Native
|
|
24
|
+
* ignores the anchor and docks the panel to the bottom as a sheet.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Clean device-account switcher, modeled on the inbox `AccountMenu` but written
|
|
29
|
+
* fresh with NativeWind classNames + Bloom primitives. Lists every account
|
|
30
|
+
* signed in on this device (from {@link useDeviceAccounts}); tapping a row
|
|
31
|
+
* switches, and each inactive row carries a sign-out icon. Below the list:
|
|
32
|
+
* Add account, Manage account, optional View profile, and Sign out of all.
|
|
33
|
+
*
|
|
34
|
+
* Renders as an upward-opening popover anchored to the trigger on web, and a
|
|
35
|
+
* bottom-sheet style modal on native.
|
|
36
|
+
*/
|
|
37
|
+
const ProfileMenu = ({
|
|
38
|
+
open,
|
|
39
|
+
onClose,
|
|
40
|
+
anchor,
|
|
41
|
+
onNavigateManage,
|
|
42
|
+
onAddAccount,
|
|
43
|
+
onNavigateProfile,
|
|
44
|
+
onBeforeSessionChange
|
|
45
|
+
}) => {
|
|
46
|
+
const {
|
|
47
|
+
activeSessionId,
|
|
48
|
+
switchSession,
|
|
49
|
+
logoutAll,
|
|
50
|
+
removeSession
|
|
51
|
+
} = useOxy();
|
|
52
|
+
const {
|
|
53
|
+
t
|
|
54
|
+
} = useI18n();
|
|
55
|
+
const {
|
|
56
|
+
colors
|
|
57
|
+
} = useTheme();
|
|
58
|
+
const {
|
|
59
|
+
accounts
|
|
60
|
+
} = useDeviceAccounts();
|
|
61
|
+
const [busySessionId, setBusySessionId] = useState(null);
|
|
62
|
+
const [removingSessionId, setRemovingSessionId] = useState(null);
|
|
63
|
+
const [signingOutAll, setSigningOutAll] = useState(false);
|
|
64
|
+
const signOutAllDialog = useDialogControl();
|
|
65
|
+
const isSwitching = busySessionId !== null;
|
|
66
|
+
const actionDisabled = isSwitching || removingSessionId !== null || signingOutAll;
|
|
67
|
+
|
|
68
|
+
// Switch to a non-active account through the SDK's canonical switch path.
|
|
69
|
+
const handleSwitch = useCallback(async sessionId => {
|
|
70
|
+
if (sessionId === activeSessionId || busySessionId) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
setBusySessionId(sessionId);
|
|
74
|
+
try {
|
|
75
|
+
await onBeforeSessionChange?.();
|
|
76
|
+
await switchSession(sessionId);
|
|
77
|
+
toast.success(t('accountSwitcher.toasts.switchSuccess') || 'Switched account');
|
|
78
|
+
onClose();
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (!isDev()) {
|
|
81
|
+
loggerUtil.warn('Switch account failed', {
|
|
82
|
+
component: 'ProfileMenu'
|
|
83
|
+
}, error);
|
|
84
|
+
}
|
|
85
|
+
toast.error(t('accountSwitcher.toasts.switchFailed') || 'Failed to switch account');
|
|
86
|
+
} finally {
|
|
87
|
+
setBusySessionId(null);
|
|
88
|
+
}
|
|
89
|
+
}, [activeSessionId, busySessionId, switchSession, t, onClose, onBeforeSessionChange]);
|
|
90
|
+
|
|
91
|
+
// Sign out a specific inactive account without switching/clearing the active
|
|
92
|
+
// one. The menu stays open so the user can keep managing accounts.
|
|
93
|
+
const handleRemove = useCallback(async sessionId => {
|
|
94
|
+
if (sessionId === activeSessionId || removingSessionId) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
setRemovingSessionId(sessionId);
|
|
98
|
+
try {
|
|
99
|
+
await removeSession(sessionId);
|
|
100
|
+
toast.success(t('common.actions.signedOut') || 'Signed out');
|
|
101
|
+
} catch (error) {
|
|
102
|
+
loggerUtil.warn('Remove account failed', {
|
|
103
|
+
component: 'ProfileMenu'
|
|
104
|
+
}, error);
|
|
105
|
+
toast.error(t('common.errors.signOutFailed') || 'Failed to sign out');
|
|
106
|
+
} finally {
|
|
107
|
+
setRemovingSessionId(null);
|
|
108
|
+
}
|
|
109
|
+
}, [activeSessionId, removingSessionId, removeSession, t]);
|
|
110
|
+
const performSignOutAll = useCallback(async () => {
|
|
111
|
+
if (signingOutAll) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
setSigningOutAll(true);
|
|
115
|
+
try {
|
|
116
|
+
await onBeforeSessionChange?.();
|
|
117
|
+
await logoutAll();
|
|
118
|
+
toast.success(t('accountSwitcher.toasts.signOutAllSuccess') || 'Signed out of all accounts');
|
|
119
|
+
onClose();
|
|
120
|
+
} catch (error) {
|
|
121
|
+
loggerUtil.warn('Sign out all failed', {
|
|
122
|
+
component: 'ProfileMenu'
|
|
123
|
+
}, error);
|
|
124
|
+
toast.error(t('common.errors.signOutAllFailed') || 'Failed to sign out of all accounts');
|
|
125
|
+
} finally {
|
|
126
|
+
setSigningOutAll(false);
|
|
127
|
+
}
|
|
128
|
+
}, [signingOutAll, logoutAll, t, onClose, onBeforeSessionChange]);
|
|
129
|
+
|
|
130
|
+
// Escape-to-close (web only).
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (!open || !isWeb || typeof document === 'undefined') {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
const onKey = event => {
|
|
136
|
+
if (event.key === 'Escape') {
|
|
137
|
+
event.stopPropagation();
|
|
138
|
+
onClose();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
document.addEventListener('keydown', onKey, true);
|
|
142
|
+
return () => document.removeEventListener('keydown', onKey, true);
|
|
143
|
+
}, [open, onClose]);
|
|
144
|
+
if (!open) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Web: anchor the panel's bottom-left corner to the measured trigger, falling
|
|
149
|
+
// back to a bottom-left placement when no anchor was captured. Native ignores
|
|
150
|
+
// this (the panel docks to the bottom via the overlay's flex-end).
|
|
151
|
+
const panelAnchorStyle = isWeb ? {
|
|
152
|
+
position: 'absolute',
|
|
153
|
+
width: MENU_WIDTH,
|
|
154
|
+
left: anchor?.left ?? 8,
|
|
155
|
+
bottom: anchor?.bottom ?? 8
|
|
156
|
+
} : undefined;
|
|
157
|
+
const content = /*#__PURE__*/_jsx(Pressable
|
|
158
|
+
// Swallow taps inside the panel so they never reach the overlay's
|
|
159
|
+
// outside-tap-to-close handler.
|
|
160
|
+
, {
|
|
161
|
+
onPress: () => undefined,
|
|
162
|
+
className: isWeb ? 'overflow-hidden rounded-2xl border border-border bg-background' : 'overflow-hidden rounded-t-3xl bg-background pb-3',
|
|
163
|
+
style: [panelAnchorStyle, !isWeb ? {
|
|
164
|
+
maxHeight: '85%'
|
|
165
|
+
} : {
|
|
166
|
+
maxHeight: '85%'
|
|
167
|
+
}, styles.shadow],
|
|
168
|
+
accessibilityRole: "menu",
|
|
169
|
+
accessibilityLabel: t('accountMenu.label') || 'Account menu',
|
|
170
|
+
children: /*#__PURE__*/_jsxs(ScrollView, {
|
|
171
|
+
className: "grow-0",
|
|
172
|
+
contentContainerClassName: "py-1",
|
|
173
|
+
showsVerticalScrollIndicator: false,
|
|
174
|
+
children: [accounts.map(account => {
|
|
175
|
+
const isActive = account.isCurrent;
|
|
176
|
+
const isBusy = busySessionId === account.sessionId;
|
|
177
|
+
const isRemoving = removingSessionId === account.sessionId;
|
|
178
|
+
return /*#__PURE__*/_jsxs(Pressable, {
|
|
179
|
+
accessibilityRole: "menuitem",
|
|
180
|
+
accessibilityLabel: account.displayName,
|
|
181
|
+
accessibilityState: {
|
|
182
|
+
selected: isActive
|
|
183
|
+
},
|
|
184
|
+
onPress: () => handleSwitch(account.sessionId),
|
|
185
|
+
disabled: isActive || isBusy || isSwitching,
|
|
186
|
+
className: `flex-row items-center gap-3 px-4 py-2.5 ${isActive ? 'bg-secondary' : ''} ${isSwitching && !isActive ? 'opacity-40' : ''}`,
|
|
187
|
+
children: [/*#__PURE__*/_jsx(Avatar, {
|
|
188
|
+
source: account.user.avatar ?? undefined,
|
|
189
|
+
uri: account.avatarUrl,
|
|
190
|
+
variant: "thumb",
|
|
191
|
+
name: account.displayName,
|
|
192
|
+
size: isActive ? 40 : 32
|
|
193
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
194
|
+
className: "min-w-0 flex-1",
|
|
195
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
196
|
+
className: `text-foreground ${isActive ? 'font-semibold' : 'font-medium'}`,
|
|
197
|
+
numberOfLines: 1,
|
|
198
|
+
children: account.displayName
|
|
199
|
+
}), account.email ? /*#__PURE__*/_jsx(Text, {
|
|
200
|
+
className: "text-xs text-muted-foreground",
|
|
201
|
+
numberOfLines: 1,
|
|
202
|
+
children: account.email
|
|
203
|
+
}) : null]
|
|
204
|
+
}), isBusy ? /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
205
|
+
color: colors.primary,
|
|
206
|
+
size: "small"
|
|
207
|
+
}) : isActive ? /*#__PURE__*/_jsx(MaterialCommunityIcons, {
|
|
208
|
+
name: "check",
|
|
209
|
+
size: 20,
|
|
210
|
+
color: colors.primary
|
|
211
|
+
}) : isRemoving ? /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
212
|
+
color: colors.textSecondary,
|
|
213
|
+
size: "small"
|
|
214
|
+
}) : /*#__PURE__*/_jsx(Pressable, {
|
|
215
|
+
accessibilityRole: "button",
|
|
216
|
+
accessibilityLabel: t('accountMenu.signOutAccount', {
|
|
217
|
+
name: account.displayName
|
|
218
|
+
}) || `Sign out ${account.displayName}`,
|
|
219
|
+
onPress: () => handleRemove(account.sessionId),
|
|
220
|
+
disabled: actionDisabled,
|
|
221
|
+
hitSlop: {
|
|
222
|
+
top: 8,
|
|
223
|
+
bottom: 8,
|
|
224
|
+
left: 8,
|
|
225
|
+
right: 8
|
|
226
|
+
},
|
|
227
|
+
className: "h-7 w-7 items-center justify-center rounded-full opacity-60",
|
|
228
|
+
children: /*#__PURE__*/_jsx(MaterialCommunityIcons, {
|
|
229
|
+
name: "logout",
|
|
230
|
+
size: 18,
|
|
231
|
+
color: colors.textSecondary
|
|
232
|
+
})
|
|
233
|
+
})]
|
|
234
|
+
}, `account-${account.sessionId}`);
|
|
235
|
+
}), isSwitching ? /*#__PURE__*/_jsxs(View, {
|
|
236
|
+
className: "flex-row items-center justify-center gap-2 py-2",
|
|
237
|
+
children: [/*#__PURE__*/_jsx(ActivityIndicator, {
|
|
238
|
+
color: colors.textSecondary,
|
|
239
|
+
size: "small"
|
|
240
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
241
|
+
className: "text-xs font-medium text-muted-foreground",
|
|
242
|
+
children: t('accountMenu.switching') || 'Switching account…'
|
|
243
|
+
})]
|
|
244
|
+
}) : null, /*#__PURE__*/_jsx(Divider, {
|
|
245
|
+
color: colors.border,
|
|
246
|
+
spacing: 4
|
|
247
|
+
}), /*#__PURE__*/_jsx(ActionRow, {
|
|
248
|
+
icon: "account-plus-outline",
|
|
249
|
+
iconColor: colors.icon,
|
|
250
|
+
label: t('accountMenu.addAnother') || 'Add another account',
|
|
251
|
+
disabled: actionDisabled,
|
|
252
|
+
onPress: () => {
|
|
253
|
+
onClose();
|
|
254
|
+
onAddAccount();
|
|
255
|
+
}
|
|
256
|
+
}), /*#__PURE__*/_jsx(ActionRow, {
|
|
257
|
+
icon: "cog-outline",
|
|
258
|
+
iconColor: colors.icon,
|
|
259
|
+
label: t('accountMenu.manage') || 'Manage your Oxy Account',
|
|
260
|
+
disabled: actionDisabled,
|
|
261
|
+
onPress: () => {
|
|
262
|
+
onClose();
|
|
263
|
+
onNavigateManage();
|
|
264
|
+
}
|
|
265
|
+
}), onNavigateProfile ? /*#__PURE__*/_jsx(ActionRow, {
|
|
266
|
+
icon: "account-outline",
|
|
267
|
+
iconColor: colors.icon,
|
|
268
|
+
label: t('accountMenu.viewProfile') || 'View profile',
|
|
269
|
+
disabled: actionDisabled,
|
|
270
|
+
onPress: () => {
|
|
271
|
+
onClose();
|
|
272
|
+
onNavigateProfile();
|
|
273
|
+
}
|
|
274
|
+
}) : null, /*#__PURE__*/_jsx(Divider, {
|
|
275
|
+
color: colors.border,
|
|
276
|
+
spacing: 4
|
|
277
|
+
}), /*#__PURE__*/_jsxs(Pressable, {
|
|
278
|
+
accessibilityRole: "menuitem",
|
|
279
|
+
accessibilityLabel: t('accountMenu.signOutAll') || 'Sign out of all accounts',
|
|
280
|
+
onPress: () => signOutAllDialog.open(),
|
|
281
|
+
disabled: actionDisabled,
|
|
282
|
+
className: `flex-row items-center gap-3 px-4 py-3 ${actionDisabled ? 'opacity-40' : ''}`,
|
|
283
|
+
children: [signingOutAll ? /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
284
|
+
color: colors.error,
|
|
285
|
+
size: "small"
|
|
286
|
+
}) : /*#__PURE__*/_jsx(MaterialCommunityIcons, {
|
|
287
|
+
name: "logout",
|
|
288
|
+
size: 18,
|
|
289
|
+
color: colors.error
|
|
290
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
291
|
+
className: "font-medium",
|
|
292
|
+
style: {
|
|
293
|
+
color: colors.error
|
|
294
|
+
},
|
|
295
|
+
children: t('accountMenu.signOutAll') || 'Sign out of all accounts'
|
|
296
|
+
})]
|
|
297
|
+
})]
|
|
298
|
+
})
|
|
299
|
+
});
|
|
300
|
+
return /*#__PURE__*/_jsxs(Modal, {
|
|
301
|
+
visible: open,
|
|
302
|
+
transparent: true,
|
|
303
|
+
animationType: isWeb ? 'fade' : 'slide',
|
|
304
|
+
onRequestClose: onClose,
|
|
305
|
+
children: [/*#__PURE__*/_jsx(Pressable, {
|
|
306
|
+
accessibilityRole: "button",
|
|
307
|
+
accessibilityLabel: t('common.actions.close') || 'Close',
|
|
308
|
+
onPress: onClose,
|
|
309
|
+
className: isWeb ? 'flex-1 relative' : 'flex-1 justify-end',
|
|
310
|
+
style: !isWeb ? styles.nativeScrim : undefined,
|
|
311
|
+
children: content
|
|
312
|
+
}), /*#__PURE__*/_jsx(Dialog, {
|
|
313
|
+
control: signOutAllDialog,
|
|
314
|
+
title: t('accountMenu.signOutAll') || 'Sign out of all accounts',
|
|
315
|
+
description: t('common.confirms.signOutAll') || 'Are you sure you want to sign out of all accounts?',
|
|
316
|
+
actions: [{
|
|
317
|
+
label: t('accountMenu.signOutAll') || 'Sign out of all accounts',
|
|
318
|
+
color: 'destructive',
|
|
319
|
+
onPress: performSignOutAll
|
|
320
|
+
}, {
|
|
321
|
+
label: t('common.cancel') || 'Cancel',
|
|
322
|
+
color: 'cancel'
|
|
323
|
+
}]
|
|
324
|
+
})]
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
/** Bottom-section action row (Add account / Manage / View profile). */
|
|
329
|
+
const ActionRow = ({
|
|
330
|
+
icon,
|
|
331
|
+
iconColor,
|
|
332
|
+
label,
|
|
333
|
+
disabled,
|
|
334
|
+
onPress
|
|
335
|
+
}) => /*#__PURE__*/_jsxs(Pressable, {
|
|
336
|
+
accessibilityRole: "menuitem",
|
|
337
|
+
accessibilityLabel: label,
|
|
338
|
+
onPress: onPress,
|
|
339
|
+
disabled: disabled,
|
|
340
|
+
className: `flex-row items-center gap-3 px-4 py-3 ${disabled ? 'opacity-40' : ''}`,
|
|
341
|
+
children: [/*#__PURE__*/_jsx(MaterialCommunityIcons, {
|
|
342
|
+
name: icon,
|
|
343
|
+
size: 20,
|
|
344
|
+
color: iconColor
|
|
345
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
346
|
+
className: "font-medium text-foreground",
|
|
347
|
+
children: label
|
|
348
|
+
})]
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// The panel's drop shadow and the native scrim are the only values with no
|
|
352
|
+
// NativeWind class equivalent in this package (dynamic elevation + rgba scrim),
|
|
353
|
+
// so they stay as small inline objects rather than raw class-replaceable styles.
|
|
354
|
+
const styles = {
|
|
355
|
+
shadow: {
|
|
356
|
+
shadowColor: '#000',
|
|
357
|
+
shadowOpacity: 0.18,
|
|
358
|
+
shadowRadius: 24,
|
|
359
|
+
shadowOffset: {
|
|
360
|
+
width: 0,
|
|
361
|
+
height: 8
|
|
362
|
+
},
|
|
363
|
+
elevation: 12
|
|
364
|
+
},
|
|
365
|
+
nativeScrim: {
|
|
366
|
+
backgroundColor: 'rgba(0,0,0,0.32)'
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
export default ProfileMenu;
|
|
370
|
+
//# sourceMappingURL=ProfileMenu.js.map
|