@buoy-gg/impersonate 7.0.41 → 7.0.43
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/README.md +12 -80
- package/lib/commonjs/impersonate/components/DataNukeSettings.js +8 -675
- package/lib/commonjs/impersonate/components/ImpersonateBanner.js +1 -221
- package/lib/commonjs/impersonate/components/ImpersonateHistoryList.js +1 -181
- package/lib/commonjs/impersonate/components/ImpersonateModal.js +1 -319
- package/lib/commonjs/impersonate/components/ImpersonateOverlay.js +1 -26
- package/lib/commonjs/impersonate/components/ImpersonateStatusBar.js +1 -130
- package/lib/commonjs/impersonate/components/UserAvatar.js +1 -146
- package/lib/commonjs/impersonate/components/UserCard.js +1 -201
- package/lib/commonjs/impersonate/components/UserSearchView.js +1 -227
- package/lib/commonjs/impersonate/hooks/asyncStoragePeer.js +1 -17
- package/lib/commonjs/impersonate/hooks/asyncStoragePeer.web.js +1 -11
- package/lib/commonjs/impersonate/hooks/useAutoClearAsyncStorage.js +1 -134
- package/lib/commonjs/impersonate/hooks/useAutoClearReactQuery.js +1 -155
- package/lib/commonjs/impersonate/hooks/useAutoClearReactQuery.web.js +1 -20
- package/lib/commonjs/impersonate/hooks/useAutoClearRedux.js +1 -188
- package/lib/commonjs/impersonate/hooks/useAutoClearRedux.web.js +1 -27
- package/lib/commonjs/impersonate/hooks/useImpersonate.js +1 -215
- package/lib/commonjs/impersonate/hooks/useImpersonateHistory.js +1 -56
- package/lib/commonjs/impersonate/types/index.js +1 -16
- package/lib/commonjs/impersonate/types/types.js +1 -1
- package/lib/commonjs/impersonate/utils/impersonateListener.js +1 -350
- package/lib/commonjs/impersonate/utils/impersonateStore.js +1 -689
- package/lib/commonjs/index.js +1 -150
- package/lib/commonjs/preset.js +1 -232
- package/lib/commonjs/sync/impersonateSyncAdapter.js +1 -170
- package/lib/module/impersonate/components/DataNukeSettings.js +8 -670
- package/lib/module/impersonate/components/ImpersonateBanner.js +1 -215
- package/lib/module/impersonate/components/ImpersonateHistoryList.js +1 -176
- package/lib/module/impersonate/components/ImpersonateModal.js +1 -314
- package/lib/module/impersonate/components/ImpersonateOverlay.js +1 -21
- package/lib/module/impersonate/components/ImpersonateStatusBar.js +1 -125
- package/lib/module/impersonate/components/UserAvatar.js +1 -140
- package/lib/module/impersonate/components/UserCard.js +1 -196
- package/lib/module/impersonate/components/UserSearchView.js +1 -222
- package/lib/module/impersonate/hooks/asyncStoragePeer.js +1 -13
- package/lib/module/impersonate/hooks/asyncStoragePeer.web.js +1 -6
- package/lib/module/impersonate/hooks/useAutoClearAsyncStorage.js +1 -130
- package/lib/module/impersonate/hooks/useAutoClearReactQuery.js +1 -151
- package/lib/module/impersonate/hooks/useAutoClearReactQuery.web.js +1 -16
- package/lib/module/impersonate/hooks/useAutoClearRedux.js +1 -183
- package/lib/module/impersonate/hooks/useAutoClearRedux.web.js +1 -22
- package/lib/module/impersonate/hooks/useImpersonate.js +1 -212
- package/lib/module/impersonate/hooks/useImpersonateHistory.js +1 -52
- package/lib/module/impersonate/types/index.js +1 -3
- package/lib/module/impersonate/types/types.js +1 -1
- package/lib/module/impersonate/utils/impersonateListener.js +1 -341
- package/lib/module/impersonate/utils/impersonateStore.js +1 -686
- package/lib/module/index.js +1 -117
- package/lib/module/preset.js +1 -216
- package/lib/module/sync/impersonateSyncAdapter.js +1 -162
- package/lib/web/index.mjs +7 -8
- package/package.json +3 -6
- package/lib/typescript/impersonate/components/DataNukeSettings.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateBanner.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateHistoryList.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateModal.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateOverlay.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/ImpersonateStatusBar.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/UserAvatar.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/UserCard.d.ts.map +0 -1
- package/lib/typescript/impersonate/components/UserSearchView.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/asyncStoragePeer.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/asyncStoragePeer.web.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearAsyncStorage.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearReactQuery.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearReactQuery.web.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearRedux.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useAutoClearRedux.web.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useImpersonate.d.ts.map +0 -1
- package/lib/typescript/impersonate/hooks/useImpersonateHistory.d.ts.map +0 -1
- package/lib/typescript/impersonate/types/index.d.ts.map +0 -1
- package/lib/typescript/impersonate/types/types.d.ts.map +0 -1
- package/lib/typescript/impersonate/utils/impersonateListener.d.ts.map +0 -1
- package/lib/typescript/impersonate/utils/impersonateStore.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/sync/impersonateSyncAdapter.d.ts.map +0 -1
|
@@ -1,196 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* UserCard Component
|
|
5
|
-
*
|
|
6
|
-
* Polished user card for search results and history.
|
|
7
|
-
* Features avatar, clean typography hierarchy, and contextual actions.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import React from "react";
|
|
11
|
-
import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
|
|
12
|
-
import { buoyColors, night, Play, X, PowerToggleButton, monoFont } from "@buoy-gg/shared-ui";
|
|
13
|
-
import { UserAvatar } from "./UserAvatar";
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
export function UserCard({
|
|
16
|
-
user,
|
|
17
|
-
isActive = false,
|
|
18
|
-
onPress,
|
|
19
|
-
onStop,
|
|
20
|
-
onRemove,
|
|
21
|
-
showRemoveButton = false,
|
|
22
|
-
lastUsedTime,
|
|
23
|
-
variant = "default"
|
|
24
|
-
}) {
|
|
25
|
-
const displayName = user.displayName || user.email || user.id;
|
|
26
|
-
const showEmail = user.email && user.displayName;
|
|
27
|
-
const role = typeof user.metadata?.role === "string" ? user.metadata.role : null;
|
|
28
|
-
return /*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
29
|
-
testID: `buoy-impersonate-user-${user.id}`,
|
|
30
|
-
style: [styles.container, isActive && styles.activeContainer, variant === "compact" && styles.compactContainer],
|
|
31
|
-
onPress: onPress,
|
|
32
|
-
disabled: isActive,
|
|
33
|
-
activeOpacity: 0.7,
|
|
34
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
35
|
-
style: styles.avatarSection,
|
|
36
|
-
children: /*#__PURE__*/_jsx(UserAvatar, {
|
|
37
|
-
userId: user.id,
|
|
38
|
-
name: displayName,
|
|
39
|
-
size: variant === "compact" ? "small" : "medium",
|
|
40
|
-
showActiveIndicator: isActive
|
|
41
|
-
})
|
|
42
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
43
|
-
style: styles.content,
|
|
44
|
-
children: [/*#__PURE__*/_jsxs(View, {
|
|
45
|
-
style: styles.nameRow,
|
|
46
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
47
|
-
style: [styles.name, isActive && styles.activeName],
|
|
48
|
-
numberOfLines: 1,
|
|
49
|
-
children: displayName
|
|
50
|
-
}), role ? /*#__PURE__*/_jsx(View, {
|
|
51
|
-
style: styles.roleBadge,
|
|
52
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
53
|
-
style: styles.roleBadgeText,
|
|
54
|
-
children: role.toUpperCase()
|
|
55
|
-
})
|
|
56
|
-
}) : null]
|
|
57
|
-
}), showEmail && /*#__PURE__*/_jsx(Text, {
|
|
58
|
-
style: styles.email,
|
|
59
|
-
numberOfLines: 1,
|
|
60
|
-
children: user.email
|
|
61
|
-
}), /*#__PURE__*/_jsx(View, {
|
|
62
|
-
style: styles.metadataRow,
|
|
63
|
-
children: /*#__PURE__*/_jsxs(Text, {
|
|
64
|
-
style: styles.userId,
|
|
65
|
-
children: ["ID: ", user.id]
|
|
66
|
-
})
|
|
67
|
-
})]
|
|
68
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
69
|
-
style: styles.actions,
|
|
70
|
-
children: [isActive ? /*#__PURE__*/_jsx(PowerToggleButton, {
|
|
71
|
-
isEnabled: true,
|
|
72
|
-
onToggle: onStop || (() => {}),
|
|
73
|
-
accessibilityLabel: "Stop impersonation"
|
|
74
|
-
}) : /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
75
|
-
style: styles.actionButton,
|
|
76
|
-
onPress: onPress,
|
|
77
|
-
activeOpacity: 0.7,
|
|
78
|
-
children: /*#__PURE__*/_jsx(Play, {
|
|
79
|
-
size: 14,
|
|
80
|
-
color: night.color.onAccent
|
|
81
|
-
})
|
|
82
|
-
}), showRemoveButton && onRemove && !isActive && /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
83
|
-
style: styles.removeButton,
|
|
84
|
-
onPress: onRemove,
|
|
85
|
-
activeOpacity: 0.7,
|
|
86
|
-
children: /*#__PURE__*/_jsx(X, {
|
|
87
|
-
size: 12,
|
|
88
|
-
color: night.color.textTertiary
|
|
89
|
-
})
|
|
90
|
-
})]
|
|
91
|
-
}), lastUsedTime ? /*#__PURE__*/_jsx(Text, {
|
|
92
|
-
style: styles.lastUsed,
|
|
93
|
-
children: lastUsedTime
|
|
94
|
-
}) : null]
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
const styles = StyleSheet.create({
|
|
98
|
-
container: {
|
|
99
|
-
flexDirection: "row",
|
|
100
|
-
alignItems: "center",
|
|
101
|
-
backgroundColor: night.color.surface,
|
|
102
|
-
borderRadius: 10,
|
|
103
|
-
borderWidth: 1,
|
|
104
|
-
borderColor: night.color.border,
|
|
105
|
-
padding: 12,
|
|
106
|
-
gap: 12
|
|
107
|
-
},
|
|
108
|
-
activeContainer: {
|
|
109
|
-
backgroundColor: buoyColors.success + "10",
|
|
110
|
-
borderColor: buoyColors.success + "40"
|
|
111
|
-
},
|
|
112
|
-
compactContainer: {
|
|
113
|
-
padding: 10,
|
|
114
|
-
gap: 10
|
|
115
|
-
},
|
|
116
|
-
avatarSection: {
|
|
117
|
-
flexShrink: 0
|
|
118
|
-
},
|
|
119
|
-
content: {
|
|
120
|
-
flex: 1,
|
|
121
|
-
minWidth: 0
|
|
122
|
-
},
|
|
123
|
-
nameRow: {
|
|
124
|
-
flexDirection: "row",
|
|
125
|
-
alignItems: "center",
|
|
126
|
-
gap: 8,
|
|
127
|
-
marginBottom: 2
|
|
128
|
-
},
|
|
129
|
-
name: {
|
|
130
|
-
fontSize: 15,
|
|
131
|
-
fontWeight: "600",
|
|
132
|
-
color: night.color.text,
|
|
133
|
-
flexShrink: 1
|
|
134
|
-
},
|
|
135
|
-
activeName: {
|
|
136
|
-
color: buoyColors.success
|
|
137
|
-
},
|
|
138
|
-
roleBadge: {
|
|
139
|
-
backgroundColor: night.color.surfaceElevated,
|
|
140
|
-
paddingHorizontal: 6,
|
|
141
|
-
paddingVertical: 2,
|
|
142
|
-
borderRadius: 4
|
|
143
|
-
},
|
|
144
|
-
roleBadgeText: {
|
|
145
|
-
fontSize: 9,
|
|
146
|
-
fontWeight: "700",
|
|
147
|
-
color: night.color.textTertiary,
|
|
148
|
-
letterSpacing: 0.5
|
|
149
|
-
},
|
|
150
|
-
email: {
|
|
151
|
-
fontSize: 13,
|
|
152
|
-
color: night.color.textSecondary,
|
|
153
|
-
marginBottom: 4
|
|
154
|
-
},
|
|
155
|
-
metadataRow: {
|
|
156
|
-
flexDirection: "row",
|
|
157
|
-
alignItems: "center",
|
|
158
|
-
gap: 4
|
|
159
|
-
},
|
|
160
|
-
userId: {
|
|
161
|
-
fontSize: 11,
|
|
162
|
-
color: night.color.textTertiary,
|
|
163
|
-
fontFamily: monoFont
|
|
164
|
-
},
|
|
165
|
-
lastUsed: {
|
|
166
|
-
position: "absolute",
|
|
167
|
-
bottom: 8,
|
|
168
|
-
right: 10,
|
|
169
|
-
fontSize: 10,
|
|
170
|
-
color: night.color.textTertiary
|
|
171
|
-
},
|
|
172
|
-
actions: {
|
|
173
|
-
flexDirection: "row",
|
|
174
|
-
alignItems: "center",
|
|
175
|
-
gap: 8,
|
|
176
|
-
flexShrink: 0
|
|
177
|
-
},
|
|
178
|
-
actionButton: {
|
|
179
|
-
width: 36,
|
|
180
|
-
height: 36,
|
|
181
|
-
borderRadius: 8,
|
|
182
|
-
backgroundColor: night.color.accent,
|
|
183
|
-
alignItems: "center",
|
|
184
|
-
justifyContent: "center"
|
|
185
|
-
},
|
|
186
|
-
removeButton: {
|
|
187
|
-
width: 28,
|
|
188
|
-
height: 28,
|
|
189
|
-
borderRadius: 6,
|
|
190
|
-
backgroundColor: night.color.surfaceElevated,
|
|
191
|
-
borderWidth: 1,
|
|
192
|
-
borderColor: night.color.border,
|
|
193
|
-
alignItems: "center",
|
|
194
|
-
justifyContent: "center"
|
|
195
|
-
}
|
|
196
|
-
});
|
|
1
|
+
"use strict";import T from"react";import{View as n,Text as i,TouchableOpacity as c,StyleSheet as x}from"react-native";import{buoyColors as s,night as o,Play as C,X as S,PowerToggleButton as w,monoFont as I}from"@buoy-gg/shared-ui";import{UserAvatar as B}from"./UserAvatar";import{jsx as t,jsxs as l}from"react/jsx-runtime";export function UserCard({user:r,isActive:a=false,onPress:d,onStop:f,onRemove:m,showRemoveButton:u=false,lastUsedTime:g,variant:y="default"}){const h=r.displayName||r.email||r.id;const b=r.email&&r.displayName;const p=typeof r.metadata?.role==="string"?r.metadata.role:null;return l(c,{testID:`buoy-impersonate-user-${r.id}`,style:[e.container,a&&e.activeContainer,y==="compact"&&e.compactContainer],onPress:d,disabled:a,activeOpacity:.7,children:[t(n,{style:e.avatarSection,children:t(B,{userId:r.id,name:h,size:y==="compact"?"small":"medium",showActiveIndicator:a})}),l(n,{style:e.content,children:[l(n,{style:e.nameRow,children:[t(i,{style:[e.name,a&&e.activeName],numberOfLines:1,children:h}),p?t(n,{style:e.roleBadge,children:t(i,{style:e.roleBadgeText,children:p.toUpperCase()})}):null]}),b&&t(i,{style:e.email,numberOfLines:1,children:r.email}),t(n,{style:e.metadataRow,children:l(i,{style:e.userId,children:["ID: ",r.id]})})]}),l(n,{style:e.actions,children:[a?t(w,{isEnabled:true,onToggle:f||(()=>{}),accessibilityLabel:"Stop impersonation"}):t(c,{style:e.actionButton,onPress:d,activeOpacity:.7,children:t(C,{size:14,color:o.color.onAccent})}),u&&m&&!a&&t(c,{style:e.removeButton,onPress:m,activeOpacity:.7,children:t(S,{size:12,color:o.color.textTertiary})})]}),g?t(i,{style:e.lastUsed,children:g}):null]})}const e=x.create({container:{flexDirection:"row",alignItems:"center",backgroundColor:o.color.surface,borderRadius:10,borderWidth:1,borderColor:o.color.border,padding:12,gap:12},activeContainer:{backgroundColor:s.success+"10",borderColor:s.success+"40"},compactContainer:{padding:10,gap:10},avatarSection:{flexShrink:0},content:{flex:1,minWidth:0},nameRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:2},name:{fontSize:15,fontWeight:"600",color:o.color.text,flexShrink:1},activeName:{color:s.success},roleBadge:{backgroundColor:o.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},roleBadgeText:{fontSize:9,fontWeight:"700",color:o.color.textTertiary,letterSpacing:.5},email:{fontSize:13,color:o.color.textSecondary,marginBottom:4},metadataRow:{flexDirection:"row",alignItems:"center",gap:4},userId:{fontSize:11,color:o.color.textTertiary,fontFamily:I},lastUsed:{position:"absolute",bottom:8,right:10,fontSize:10,color:o.color.textTertiary},actions:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:0},actionButton:{width:36,height:36,borderRadius:8,backgroundColor:o.color.accent,alignItems:"center",justifyContent:"center"},removeButton:{width:28,height:28,borderRadius:6,backgroundColor:o.color.surfaceElevated,borderWidth:1,borderColor:o.color.border,alignItems:"center",justifyContent:"center"}});
|
|
@@ -1,222 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* UserSearchView Component
|
|
5
|
-
*
|
|
6
|
-
* Displays search results for user impersonation.
|
|
7
|
-
* Search input is handled by the parent modal's header.
|
|
8
|
-
* Uses polished UserCard component for results.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import React, { useCallback } from "react";
|
|
12
|
-
import { View, Text, StyleSheet, FlatList, ActivityIndicator } from "react-native";
|
|
13
|
-
import { SectionHeader, EmptyState, night, Search, AlertTriangle, Users } from "@buoy-gg/shared-ui";
|
|
14
|
-
import { UserCard } from "./UserCard";
|
|
15
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
export function UserSearchView({
|
|
17
|
-
currentUser,
|
|
18
|
-
searchQuery,
|
|
19
|
-
searchResults,
|
|
20
|
-
isSearching,
|
|
21
|
-
searchError,
|
|
22
|
-
onSelectUser,
|
|
23
|
-
onStopImpersonation,
|
|
24
|
-
searchAvailable = true
|
|
25
|
-
}) {
|
|
26
|
-
const renderUserItem = useCallback(({
|
|
27
|
-
item
|
|
28
|
-
}) => {
|
|
29
|
-
const isCurrentUser = currentUser?.id === item.id;
|
|
30
|
-
return /*#__PURE__*/_jsx(UserCard, {
|
|
31
|
-
user: item,
|
|
32
|
-
isActive: isCurrentUser,
|
|
33
|
-
onPress: () => !isCurrentUser && onSelectUser(item),
|
|
34
|
-
onStop: isCurrentUser ? onStopImpersonation : undefined
|
|
35
|
-
});
|
|
36
|
-
}, [currentUser, onSelectUser, onStopImpersonation]);
|
|
37
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
38
|
-
style: styles.container,
|
|
39
|
-
children: [!searchAvailable && /*#__PURE__*/_jsx(View, {
|
|
40
|
-
style: styles.section,
|
|
41
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
42
|
-
style: styles.warningCard,
|
|
43
|
-
children: [/*#__PURE__*/_jsx(AlertTriangle, {
|
|
44
|
-
size: 18,
|
|
45
|
-
color: night.color.warning
|
|
46
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
47
|
-
style: styles.warningContent,
|
|
48
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
49
|
-
style: styles.warningTitle,
|
|
50
|
-
children: "Search Not Available"
|
|
51
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
52
|
-
style: styles.warningText,
|
|
53
|
-
children: "Configure the onSearchUsers callback to enable user search."
|
|
54
|
-
})]
|
|
55
|
-
})]
|
|
56
|
-
})
|
|
57
|
-
}), isSearching && /*#__PURE__*/_jsxs(View, {
|
|
58
|
-
style: styles.loadingContainer,
|
|
59
|
-
children: [/*#__PURE__*/_jsx(ActivityIndicator, {
|
|
60
|
-
size: "small",
|
|
61
|
-
color: night.color.accent
|
|
62
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
63
|
-
style: styles.loadingText,
|
|
64
|
-
children: "Searching users..."
|
|
65
|
-
})]
|
|
66
|
-
}), searchError ? /*#__PURE__*/_jsx(View, {
|
|
67
|
-
style: styles.section,
|
|
68
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
69
|
-
style: styles.errorCard,
|
|
70
|
-
children: [/*#__PURE__*/_jsx(AlertTriangle, {
|
|
71
|
-
size: 16,
|
|
72
|
-
color: night.color.danger
|
|
73
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
74
|
-
style: styles.errorText,
|
|
75
|
-
children: searchError
|
|
76
|
-
})]
|
|
77
|
-
})
|
|
78
|
-
}) : null, searchResults.length > 0 && /*#__PURE__*/_jsxs(View, {
|
|
79
|
-
style: styles.resultsSection,
|
|
80
|
-
children: [/*#__PURE__*/_jsxs(SectionHeader, {
|
|
81
|
-
children: [/*#__PURE__*/_jsx(SectionHeader.Title, {
|
|
82
|
-
children: "Results"
|
|
83
|
-
}), /*#__PURE__*/_jsx(SectionHeader.Badge, {
|
|
84
|
-
count: searchResults.length
|
|
85
|
-
})]
|
|
86
|
-
}), /*#__PURE__*/_jsx(FlatList, {
|
|
87
|
-
data: searchResults,
|
|
88
|
-
keyExtractor: item => item.id,
|
|
89
|
-
renderItem: renderUserItem,
|
|
90
|
-
ItemSeparatorComponent: () => /*#__PURE__*/_jsx(View, {
|
|
91
|
-
style: styles.separator
|
|
92
|
-
}),
|
|
93
|
-
contentContainerStyle: styles.listContent,
|
|
94
|
-
showsVerticalScrollIndicator: false
|
|
95
|
-
})]
|
|
96
|
-
}), !!searchQuery && !isSearching && searchResults.length === 0 && !searchError && /*#__PURE__*/_jsxs(View, {
|
|
97
|
-
style: styles.emptyStateContainer,
|
|
98
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
99
|
-
style: styles.emptyStateIcon,
|
|
100
|
-
children: /*#__PURE__*/_jsx(Users, {
|
|
101
|
-
size: 28,
|
|
102
|
-
color: night.color.textTertiary
|
|
103
|
-
})
|
|
104
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
105
|
-
style: styles.emptyStateTitle,
|
|
106
|
-
children: "No users found"
|
|
107
|
-
}), /*#__PURE__*/_jsxs(Text, {
|
|
108
|
-
style: styles.emptyStateDescription,
|
|
109
|
-
children: ["No results for \"", searchQuery, "\""]
|
|
110
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
111
|
-
style: styles.emptyStateHint,
|
|
112
|
-
children: "Try a different search term"
|
|
113
|
-
})]
|
|
114
|
-
}), !searchQuery && searchResults.length === 0 && !isSearching && searchAvailable && /*#__PURE__*/_jsx(EmptyState, {
|
|
115
|
-
title: "Search for users",
|
|
116
|
-
description: "Tap the search icon in the header to find users by email, name, or ID",
|
|
117
|
-
icon: Search,
|
|
118
|
-
variant: "minimal"
|
|
119
|
-
})]
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
const styles = StyleSheet.create({
|
|
123
|
-
container: {
|
|
124
|
-
flex: 1
|
|
125
|
-
},
|
|
126
|
-
section: {
|
|
127
|
-
padding: 16,
|
|
128
|
-
paddingBottom: 8
|
|
129
|
-
},
|
|
130
|
-
loadingContainer: {
|
|
131
|
-
flexDirection: "row",
|
|
132
|
-
alignItems: "center",
|
|
133
|
-
justifyContent: "center",
|
|
134
|
-
gap: 10,
|
|
135
|
-
paddingVertical: 20
|
|
136
|
-
},
|
|
137
|
-
loadingText: {
|
|
138
|
-
fontSize: 13,
|
|
139
|
-
color: night.color.textSecondary
|
|
140
|
-
},
|
|
141
|
-
resultsSection: {
|
|
142
|
-
flex: 1,
|
|
143
|
-
paddingHorizontal: 16
|
|
144
|
-
},
|
|
145
|
-
listContent: {
|
|
146
|
-
paddingBottom: 16
|
|
147
|
-
},
|
|
148
|
-
separator: {
|
|
149
|
-
height: 8
|
|
150
|
-
},
|
|
151
|
-
warningCard: {
|
|
152
|
-
flexDirection: "row",
|
|
153
|
-
alignItems: "flex-start",
|
|
154
|
-
gap: 12,
|
|
155
|
-
backgroundColor: night.color.warningSoft,
|
|
156
|
-
borderRadius: 10,
|
|
157
|
-
borderWidth: 1,
|
|
158
|
-
borderColor: night.color.warning + "25",
|
|
159
|
-
padding: 14
|
|
160
|
-
},
|
|
161
|
-
warningContent: {
|
|
162
|
-
flex: 1
|
|
163
|
-
},
|
|
164
|
-
warningTitle: {
|
|
165
|
-
fontSize: 14,
|
|
166
|
-
fontWeight: "600",
|
|
167
|
-
color: night.color.warning,
|
|
168
|
-
marginBottom: 4
|
|
169
|
-
},
|
|
170
|
-
warningText: {
|
|
171
|
-
fontSize: 13,
|
|
172
|
-
color: night.color.textSecondary,
|
|
173
|
-
lineHeight: 18
|
|
174
|
-
},
|
|
175
|
-
errorCard: {
|
|
176
|
-
flexDirection: "row",
|
|
177
|
-
alignItems: "center",
|
|
178
|
-
gap: 10,
|
|
179
|
-
backgroundColor: night.color.dangerSoft,
|
|
180
|
-
borderRadius: 10,
|
|
181
|
-
borderWidth: 1,
|
|
182
|
-
borderColor: night.color.danger + "25",
|
|
183
|
-
padding: 12
|
|
184
|
-
},
|
|
185
|
-
errorText: {
|
|
186
|
-
flex: 1,
|
|
187
|
-
fontSize: 13,
|
|
188
|
-
color: night.color.danger
|
|
189
|
-
},
|
|
190
|
-
emptyStateContainer: {
|
|
191
|
-
flex: 1,
|
|
192
|
-
alignItems: "center",
|
|
193
|
-
justifyContent: "center",
|
|
194
|
-
paddingHorizontal: 32,
|
|
195
|
-
paddingVertical: 48
|
|
196
|
-
},
|
|
197
|
-
emptyStateIcon: {
|
|
198
|
-
width: 56,
|
|
199
|
-
height: 56,
|
|
200
|
-
borderRadius: 28,
|
|
201
|
-
backgroundColor: night.color.surfaceElevated,
|
|
202
|
-
alignItems: "center",
|
|
203
|
-
justifyContent: "center",
|
|
204
|
-
marginBottom: 16
|
|
205
|
-
},
|
|
206
|
-
emptyStateTitle: {
|
|
207
|
-
fontSize: 16,
|
|
208
|
-
fontWeight: "600",
|
|
209
|
-
color: night.color.text,
|
|
210
|
-
marginBottom: 6
|
|
211
|
-
},
|
|
212
|
-
emptyStateDescription: {
|
|
213
|
-
fontSize: 14,
|
|
214
|
-
color: night.color.textSecondary,
|
|
215
|
-
textAlign: "center",
|
|
216
|
-
marginBottom: 8
|
|
217
|
-
},
|
|
218
|
-
emptyStateHint: {
|
|
219
|
-
fontSize: 12,
|
|
220
|
-
color: night.color.textTertiary
|
|
221
|
-
}
|
|
222
|
-
});
|
|
1
|
+
"use strict";import k,{useCallback as C}from"react";import{View as o,Text as i,StyleSheet as u,FlatList as w,ActivityIndicator as T}from"react-native";import{SectionHeader as m,EmptyState as b,night as r,Search as z,AlertTriangle as S,Users as I}from"@buoy-gg/shared-ui";import{UserCard as j}from"./UserCard";import{jsx as e,jsxs as n}from"react/jsx-runtime";export function UserSearchView({currentUser:y,searchQuery:c,searchResults:l,isSearching:d,searchError:s,onSelectUser:f,onStopImpersonation:h,searchAvailable:p=true}){const x=C(({item:a})=>{const g=y?.id===a.id;return e(j,{user:a,isActive:g,onPress:()=>!g&&f(a),onStop:g?h:void 0})},[y,f,h]);return n(o,{style:t.container,children:[!p&&e(o,{style:t.section,children:n(o,{style:t.warningCard,children:[e(S,{size:18,color:r.color.warning}),n(o,{style:t.warningContent,children:[e(i,{style:t.warningTitle,children:"Search Not Available"}),e(i,{style:t.warningText,children:"Configure the onSearchUsers callback to enable user search."})]})]})}),d&&n(o,{style:t.loadingContainer,children:[e(T,{size:"small",color:r.color.accent}),e(i,{style:t.loadingText,children:"Searching users..."})]}),s?e(o,{style:t.section,children:n(o,{style:t.errorCard,children:[e(S,{size:16,color:r.color.danger}),e(i,{style:t.errorText,children:s})]})}):null,l.length>0&&n(o,{style:t.resultsSection,children:[n(m,{children:[e(m.Title,{children:"Results"}),e(m.Badge,{count:l.length})]}),e(w,{data:l,keyExtractor:a=>a.id,renderItem:x,ItemSeparatorComponent:()=>e(o,{style:t.separator}),contentContainerStyle:t.listContent,showsVerticalScrollIndicator:false})]}),!!c&&!d&&l.length===0&&!s&&n(o,{style:t.emptyStateContainer,children:[e(o,{style:t.emptyStateIcon,children:e(I,{size:28,color:r.color.textTertiary})}),e(i,{style:t.emptyStateTitle,children:"No users found"}),n(i,{style:t.emptyStateDescription,children:['No results for "',c,'"']}),e(i,{style:t.emptyStateHint,children:"Try a different search term"})]}),!c&&l.length===0&&!d&&p&&e(b,{title:"Search for users",description:"Tap the search icon in the header to find users by email, name, or ID",icon:z,variant:"minimal"})]})}const t=u.create({container:{flex:1},section:{padding:16,paddingBottom:8},loadingContainer:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:10,paddingVertical:20},loadingText:{fontSize:13,color:r.color.textSecondary},resultsSection:{flex:1,paddingHorizontal:16},listContent:{paddingBottom:16},separator:{height:8},warningCard:{flexDirection:"row",alignItems:"flex-start",gap:12,backgroundColor:r.color.warningSoft,borderRadius:10,borderWidth:1,borderColor:r.color.warning+"25",padding:14},warningContent:{flex:1},warningTitle:{fontSize:14,fontWeight:"600",color:r.color.warning,marginBottom:4},warningText:{fontSize:13,color:r.color.textSecondary,lineHeight:18},errorCard:{flexDirection:"row",alignItems:"center",gap:10,backgroundColor:r.color.dangerSoft,borderRadius:10,borderWidth:1,borderColor:r.color.danger+"25",padding:12},errorText:{flex:1,fontSize:13,color:r.color.danger},emptyStateContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyStateIcon:{width:56,height:56,borderRadius:28,backgroundColor:r.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyStateTitle:{fontSize:16,fontWeight:"600",color:r.color.text,marginBottom:6},emptyStateDescription:{fontSize:14,color:r.color.textSecondary,textAlign:"center",marginBottom:8},emptyStateHint:{fontSize:12,color:r.color.textTertiary}});
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
export function getAsyncStorage() {
|
|
4
|
-
try {
|
|
5
|
-
// Dynamic require to handle cases where async-storage isn't installed
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
7
|
-
const AsyncStorage = require("@react-native-async-storage/async-storage").default;
|
|
8
|
-
return AsyncStorage;
|
|
9
|
-
} catch {
|
|
10
|
-
// @react-native-async-storage/async-storage not available
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
"use strict";export function getAsyncStorage(){try{const t=require("@react-native-async-storage/async-storage").default;return t}catch{return null}}
|
|
@@ -1,130 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { getAsyncStorage } from './asyncStoragePeer';
|
|
4
|
-
/**
|
|
5
|
-
* useAutoClearAsyncStorage Hook
|
|
6
|
-
*
|
|
7
|
-
* Auto-detects AsyncStorage and provides a clear function.
|
|
8
|
-
* Follows the same pattern as useAutoClearReactQuery and useAutoClearRedux.
|
|
9
|
-
*
|
|
10
|
-
* This hook:
|
|
11
|
-
* 1. Dynamically requires @react-native-async-storage/async-storage
|
|
12
|
-
* 2. Returns a clearStorage function that removes all non-buoy keys
|
|
13
|
-
*
|
|
14
|
-
* IMPORTANT: This preserves all @buoy/* keys to avoid clearing our own state.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { useCallback, useMemo, useState, useEffect } from "react";
|
|
18
|
-
|
|
19
|
-
// ============================================
|
|
20
|
-
// Types
|
|
21
|
-
// ============================================
|
|
22
|
-
|
|
23
|
-
// Flag to prevent double-firing (synchronous check)
|
|
24
|
-
let isClearing = false;
|
|
25
|
-
// ============================================
|
|
26
|
-
// Safe Module Loading
|
|
27
|
-
// ============================================
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Safely attempt to load @react-native-async-storage/async-storage
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
// ============================================
|
|
34
|
-
// Main Hook
|
|
35
|
-
// ============================================
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Hook to auto-detect AsyncStorage and provide clearing functionality.
|
|
39
|
-
*
|
|
40
|
-
* This clears all keys EXCEPT those starting with @buoy/ to preserve
|
|
41
|
-
* our own persisted state (impersonation settings, history, etc.).
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```tsx
|
|
45
|
-
* function MyComponent() {
|
|
46
|
-
* const { isAvailable, clearStorage } = useAutoClearAsyncStorage();
|
|
47
|
-
*
|
|
48
|
-
* if (isAvailable && clearStorage) {
|
|
49
|
-
* // Clear all app data except Buoy state
|
|
50
|
-
* await clearStorage();
|
|
51
|
-
* }
|
|
52
|
-
* }
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export function useAutoClearAsyncStorage() {
|
|
56
|
-
const [asyncStorage, setAsyncStorage] = useState(null);
|
|
57
|
-
const [error, setError] = useState(null);
|
|
58
|
-
|
|
59
|
-
// Check for AsyncStorage on mount
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
const storage = getAsyncStorage();
|
|
62
|
-
if (storage) {
|
|
63
|
-
setAsyncStorage(storage);
|
|
64
|
-
setError(null);
|
|
65
|
-
} else {
|
|
66
|
-
setError("@react-native-async-storage/async-storage is not installed");
|
|
67
|
-
}
|
|
68
|
-
}, []);
|
|
69
|
-
|
|
70
|
-
// Create the clearStorage function with guard to prevent double-firing
|
|
71
|
-
const clearStorage = useCallback(async () => {
|
|
72
|
-
// Synchronous guard - set flag immediately before any async work
|
|
73
|
-
if (isClearing) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
isClearing = true;
|
|
77
|
-
try {
|
|
78
|
-
if (asyncStorage) {
|
|
79
|
-
// Get all keys
|
|
80
|
-
const allKeys = await asyncStorage.getAllKeys();
|
|
81
|
-
|
|
82
|
-
// Filter out @buoy/* keys to preserve our own state
|
|
83
|
-
const keysToRemove = allKeys.filter(key => !key.startsWith("@buoy/") && !key.startsWith("@buoy-"));
|
|
84
|
-
if (keysToRemove.length > 0) {
|
|
85
|
-
await asyncStorage.multiRemove([...keysToRemove]);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
} finally {
|
|
89
|
-
// Reset flag after a short delay to allow next legitimate call
|
|
90
|
-
setTimeout(() => {
|
|
91
|
-
isClearing = false;
|
|
92
|
-
}, 100);
|
|
93
|
-
}
|
|
94
|
-
}, [asyncStorage]);
|
|
95
|
-
|
|
96
|
-
// Memoize result
|
|
97
|
-
const result = useMemo(() => {
|
|
98
|
-
if (!asyncStorage || error) {
|
|
99
|
-
return {
|
|
100
|
-
isAvailable: false,
|
|
101
|
-
error: error || "@react-native-async-storage/async-storage is not available",
|
|
102
|
-
clearStorage: null
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
isAvailable: true,
|
|
107
|
-
error: null,
|
|
108
|
-
clearStorage
|
|
109
|
-
};
|
|
110
|
-
}, [asyncStorage, error, clearStorage]);
|
|
111
|
-
return result;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Lightweight check to see if AsyncStorage is available
|
|
116
|
-
* without creating the clear function
|
|
117
|
-
*/
|
|
118
|
-
export function useAsyncStorageAvailability() {
|
|
119
|
-
const storage = getAsyncStorage();
|
|
120
|
-
if (!storage) {
|
|
121
|
-
return {
|
|
122
|
-
isInstalled: false,
|
|
123
|
-
error: "@react-native-async-storage/async-storage is not installed"
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
isInstalled: true,
|
|
128
|
-
error: null
|
|
129
|
-
};
|
|
130
|
-
}
|
|
1
|
+
"use strict";import{getAsyncStorage as i}from"./asyncStoragePeer";import{useCallback as y,useMemo as f,useState as c,useEffect as m}from"react";let s=false;export function useAutoClearAsyncStorage(){const[e,u]=c(null);const[r,a]=c(null);m(()=>{const t=i();if(t){u(t);a(null)}else{a("@react-native-async-storage/async-storage is not installed")}},[]);const l=y(async()=>{if(s){return}s=true;try{if(e){const t=await e.getAllKeys();const n=t.filter(o=>!o.startsWith("@buoy/")&&!o.startsWith("@buoy-"));if(n.length>0){await e.multiRemove([...n])}}}finally{setTimeout(()=>{s=false},100)}},[e]);const g=f(()=>{if(!e||r){return{isAvailable:false,error:r||"@react-native-async-storage/async-storage is not available",clearStorage:null}}return{isAvailable:true,error:null,clearStorage:l}},[e,r,l]);return g}export function useAsyncStorageAvailability(){const e=i();if(!e){return{isInstalled:false,error:"@react-native-async-storage/async-storage is not installed"}}return{isInstalled:true,error:null}}
|