@oxyhq/services 13.0.3 → 13.1.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 (61) hide show
  1. package/lib/commonjs/index.js +18 -0
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/ui/components/ProfileButton.js +233 -0
  4. package/lib/commonjs/ui/components/ProfileButton.js.map +1 -0
  5. package/lib/commonjs/ui/components/ProfileMenu.js +374 -0
  6. package/lib/commonjs/ui/components/ProfileMenu.js.map +1 -0
  7. package/lib/commonjs/ui/context/OxyContext.js +99 -18
  8. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  9. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +28 -1
  10. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  11. package/lib/commonjs/ui/index.js +14 -0
  12. package/lib/commonjs/ui/index.js.map +1 -1
  13. package/lib/commonjs/ui/utils/activeAuthuser.js +76 -8
  14. package/lib/commonjs/ui/utils/activeAuthuser.js.map +1 -1
  15. package/lib/module/index.js +5 -0
  16. package/lib/module/index.js.map +1 -1
  17. package/lib/module/ui/components/ProfileButton.js +228 -0
  18. package/lib/module/ui/components/ProfileButton.js.map +1 -0
  19. package/lib/module/ui/components/ProfileMenu.js +370 -0
  20. package/lib/module/ui/components/ProfileMenu.js.map +1 -0
  21. package/lib/module/ui/context/OxyContext.js +100 -19
  22. package/lib/module/ui/context/OxyContext.js.map +1 -1
  23. package/lib/module/ui/context/hooks/useAuthOperations.js +29 -2
  24. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  25. package/lib/module/ui/index.js +2 -0
  26. package/lib/module/ui/index.js.map +1 -1
  27. package/lib/module/ui/utils/activeAuthuser.js +74 -9
  28. package/lib/module/ui/utils/activeAuthuser.js.map +1 -1
  29. package/lib/typescript/commonjs/index.d.ts +4 -0
  30. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  31. package/lib/typescript/commonjs/ui/components/ProfileButton.d.ts +46 -0
  32. package/lib/typescript/commonjs/ui/components/ProfileButton.d.ts.map +1 -0
  33. package/lib/typescript/commonjs/ui/components/ProfileMenu.d.ts +39 -0
  34. package/lib/typescript/commonjs/ui/components/ProfileMenu.d.ts.map +1 -0
  35. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  37. package/lib/typescript/commonjs/ui/index.d.ts +2 -0
  38. package/lib/typescript/commonjs/ui/index.d.ts.map +1 -1
  39. package/lib/typescript/commonjs/ui/utils/activeAuthuser.d.ts +24 -0
  40. package/lib/typescript/commonjs/ui/utils/activeAuthuser.d.ts.map +1 -1
  41. package/lib/typescript/module/index.d.ts +4 -0
  42. package/lib/typescript/module/index.d.ts.map +1 -1
  43. package/lib/typescript/module/ui/components/ProfileButton.d.ts +46 -0
  44. package/lib/typescript/module/ui/components/ProfileButton.d.ts.map +1 -0
  45. package/lib/typescript/module/ui/components/ProfileMenu.d.ts +39 -0
  46. package/lib/typescript/module/ui/components/ProfileMenu.d.ts.map +1 -0
  47. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  48. package/lib/typescript/module/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  49. package/lib/typescript/module/ui/index.d.ts +2 -0
  50. package/lib/typescript/module/ui/index.d.ts.map +1 -1
  51. package/lib/typescript/module/ui/utils/activeAuthuser.d.ts +24 -0
  52. package/lib/typescript/module/ui/utils/activeAuthuser.d.ts.map +1 -1
  53. package/package.json +3 -3
  54. package/src/index.ts +8 -0
  55. package/src/ui/components/ProfileButton.tsx +270 -0
  56. package/src/ui/components/ProfileMenu.tsx +416 -0
  57. package/src/ui/context/OxyContext.tsx +100 -18
  58. package/src/ui/context/hooks/useAuthOperations.ts +35 -2
  59. package/src/ui/index.ts +2 -0
  60. package/src/ui/utils/__tests__/activeAuthuser.test.ts +75 -0
  61. package/src/ui/utils/activeAuthuser.ts +74 -8
@@ -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,SAAA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EM;MAAY,CAAC,CAAC,IAC9E,gCAAgCA,WAAW,EAAG;MAAAb,QAAA,GAEpDgB,UAAU,eACXlE,KAAA,CAACf,IAAI;QAAC2B,SAAS,EAAC,gBAAgB;QAAAsC,QAAA,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
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useEffect","useState","View","Pressable","Modal","ScrollView","ActivityIndicator","Platform","MaterialCommunityIcons","Avatar","Text","useTheme","toast","useDialogControl","Dialog","Divider","isDev","logger","loggerUtil","useOxy","useI18n","useDeviceAccounts","jsx","_jsx","jsxs","_jsxs","isWeb","OS","MENU_WIDTH","ProfileMenu","open","onClose","anchor","onNavigateManage","onAddAccount","onNavigateProfile","onBeforeSessionChange","activeSessionId","switchSession","logoutAll","removeSession","t","colors","accounts","busySessionId","setBusySessionId","removingSessionId","setRemovingSessionId","signingOutAll","setSigningOutAll","signOutAllDialog","isSwitching","actionDisabled","handleSwitch","sessionId","success","error","warn","component","handleRemove","performSignOutAll","document","undefined","onKey","event","key","stopPropagation","addEventListener","removeEventListener","panelAnchorStyle","position","width","left","bottom","content","onPress","className","style","maxHeight","styles","shadow","accessibilityRole","accessibilityLabel","children","contentContainerClassName","showsVerticalScrollIndicator","map","account","isActive","isCurrent","isBusy","isRemoving","displayName","accessibilityState","selected","disabled","source","user","avatar","uri","avatarUrl","variant","name","size","numberOfLines","email","color","primary","textSecondary","hitSlop","top","right","border","spacing","ActionRow","icon","iconColor","label","visible","transparent","animationType","onRequestClose","nativeScrim","control","title","description","actions","shadowColor","shadowOpacity","shadowRadius","shadowOffset","height","elevation","backgroundColor"],"sourceRoot":"../../../../src","sources":["ui/components/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