@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,221 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ImpersonateBanner = ImpersonateBanner;
|
|
7
|
-
exports.ImpersonateBannerMinimal = ImpersonateBannerMinimal;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _reactNative = require("react-native");
|
|
10
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
11
|
-
var _impersonateStore = require("../utils/impersonateStore");
|
|
12
|
-
var _UserAvatar = require("./UserAvatar");
|
|
13
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
|
-
/**
|
|
16
|
-
* ImpersonateBanner Component
|
|
17
|
-
*
|
|
18
|
-
* A floating banner that shows when impersonation is active.
|
|
19
|
-
* Features polished design with avatar and elegant animations.
|
|
20
|
-
* Can be positioned at top or bottom of the screen.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Floating banner showing impersonation status
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```tsx
|
|
28
|
-
* function App() {
|
|
29
|
-
* return (
|
|
30
|
-
* <>
|
|
31
|
-
* <MainContent />
|
|
32
|
-
* <ImpersonateBanner
|
|
33
|
-
* position="top"
|
|
34
|
-
* offset={60}
|
|
35
|
-
* onPress={() => openImpersonateModal()}
|
|
36
|
-
* />
|
|
37
|
-
* </>
|
|
38
|
-
* );
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
function ImpersonateBanner({
|
|
43
|
-
onPress,
|
|
44
|
-
onStopPress,
|
|
45
|
-
position = "top",
|
|
46
|
-
offset = 50
|
|
47
|
-
}) {
|
|
48
|
-
const state = (0, _react.useSyncExternalStore)(_impersonateStore.impersonateStore.subscribe, _impersonateStore.impersonateStore.getSnapshot, _impersonateStore.impersonateStore.getSnapshot);
|
|
49
|
-
|
|
50
|
-
// Don't render if not impersonating or banner is disabled
|
|
51
|
-
if (!state.isActive || !state.currentUser || !state.showBanner) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
const handlePauseResume = async () => {
|
|
55
|
-
// eslint-disable-next-line no-console
|
|
56
|
-
console.log("[impersonate] banner pause/resume pressed");
|
|
57
|
-
if (state.isPaused) {
|
|
58
|
-
await _impersonateStore.impersonateStore.resumeImpersonation();
|
|
59
|
-
} else {
|
|
60
|
-
await _impersonateStore.impersonateStore.pauseImpersonation();
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const displayName = state.currentUser.displayName || state.currentUser.email || state.currentUser.id;
|
|
64
|
-
const positionStyle = position === "top" ? {
|
|
65
|
-
top: offset
|
|
66
|
-
} : {
|
|
67
|
-
bottom: offset
|
|
68
|
-
};
|
|
69
|
-
const handleStop = async () => {
|
|
70
|
-
// eslint-disable-next-line no-console
|
|
71
|
-
console.log("[impersonate] banner STOP pressed");
|
|
72
|
-
await _impersonateStore.impersonateStore.stopImpersonation();
|
|
73
|
-
};
|
|
74
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
75
|
-
style: [styles.container, positionStyle],
|
|
76
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
77
|
-
style: styles.banner,
|
|
78
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
|
|
79
|
-
style: styles.userSection,
|
|
80
|
-
onPress: onPress,
|
|
81
|
-
activeOpacity: 0.7,
|
|
82
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_UserAvatar.UserAvatar, {
|
|
83
|
-
userId: state.currentUser.id,
|
|
84
|
-
name: displayName,
|
|
85
|
-
size: "small",
|
|
86
|
-
showActiveIndicator: false
|
|
87
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
88
|
-
style: [styles.userName, state.isPaused && styles.userNamePaused],
|
|
89
|
-
numberOfLines: 1,
|
|
90
|
-
children: displayName
|
|
91
|
-
})]
|
|
92
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.PowerToggleButton, {
|
|
93
|
-
isEnabled: !state.isPaused,
|
|
94
|
-
onToggle: handlePauseResume,
|
|
95
|
-
size: "small",
|
|
96
|
-
accessibilityLabel: "Toggle impersonation"
|
|
97
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
98
|
-
style: styles.closeButton,
|
|
99
|
-
onPress: handleStop,
|
|
100
|
-
activeOpacity: 0.7,
|
|
101
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.X, {
|
|
102
|
-
size: 12,
|
|
103
|
-
color: "rgba(255, 255, 255, 0.5)"
|
|
104
|
-
})
|
|
105
|
-
})]
|
|
106
|
-
})
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Minimal banner variant - just an indicator badge
|
|
112
|
-
*/
|
|
113
|
-
function ImpersonateBannerMinimal({
|
|
114
|
-
onPress
|
|
115
|
-
}) {
|
|
116
|
-
const state = (0, _react.useSyncExternalStore)(_impersonateStore.impersonateStore.subscribe, _impersonateStore.impersonateStore.getSnapshot, _impersonateStore.impersonateStore.getSnapshot);
|
|
117
|
-
if (!state.isActive || !state.currentUser) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
|
|
121
|
-
style: styles.minimalBanner,
|
|
122
|
-
onPress: onPress,
|
|
123
|
-
activeOpacity: 0.8,
|
|
124
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
125
|
-
style: styles.minimalDot
|
|
126
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
127
|
-
style: styles.minimalText,
|
|
128
|
-
children: "IMP"
|
|
129
|
-
})]
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
const styles = _reactNative.StyleSheet.create({
|
|
133
|
-
container: {
|
|
134
|
-
position: "absolute",
|
|
135
|
-
left: 0,
|
|
136
|
-
right: 0,
|
|
137
|
-
alignItems: "center",
|
|
138
|
-
zIndex: 9999,
|
|
139
|
-
pointerEvents: "box-none"
|
|
140
|
-
},
|
|
141
|
-
banner: {
|
|
142
|
-
flexDirection: "row",
|
|
143
|
-
alignItems: "center",
|
|
144
|
-
backgroundColor: "rgba(20, 20, 20, 0.94)",
|
|
145
|
-
borderWidth: 1,
|
|
146
|
-
borderColor: _sharedUi.buoyColors.success + "40",
|
|
147
|
-
borderRadius: 22,
|
|
148
|
-
paddingVertical: 7,
|
|
149
|
-
paddingLeft: 7,
|
|
150
|
-
paddingRight: 10,
|
|
151
|
-
gap: 10,
|
|
152
|
-
marginTop: 3,
|
|
153
|
-
shadowColor: "#000",
|
|
154
|
-
shadowOffset: {
|
|
155
|
-
width: 0,
|
|
156
|
-
height: 6
|
|
157
|
-
},
|
|
158
|
-
shadowOpacity: 0.3,
|
|
159
|
-
shadowRadius: 14,
|
|
160
|
-
elevation: 10
|
|
161
|
-
},
|
|
162
|
-
userSection: {
|
|
163
|
-
flexDirection: "row",
|
|
164
|
-
alignItems: "center",
|
|
165
|
-
gap: 10
|
|
166
|
-
},
|
|
167
|
-
userName: {
|
|
168
|
-
fontSize: 14,
|
|
169
|
-
fontWeight: "600",
|
|
170
|
-
color: "#fff",
|
|
171
|
-
maxWidth: 180
|
|
172
|
-
},
|
|
173
|
-
userNamePaused: {
|
|
174
|
-
opacity: 0.6
|
|
175
|
-
},
|
|
176
|
-
closeButton: {
|
|
177
|
-
width: 22,
|
|
178
|
-
height: 22,
|
|
179
|
-
borderRadius: 11,
|
|
180
|
-
backgroundColor: "rgba(128, 128, 128, 0.16)",
|
|
181
|
-
alignItems: "center",
|
|
182
|
-
justifyContent: "center",
|
|
183
|
-
marginLeft: -4
|
|
184
|
-
},
|
|
185
|
-
// Minimal variant
|
|
186
|
-
minimalBanner: {
|
|
187
|
-
position: "absolute",
|
|
188
|
-
top: 60,
|
|
189
|
-
right: 16,
|
|
190
|
-
flexDirection: "row",
|
|
191
|
-
alignItems: "center",
|
|
192
|
-
backgroundColor: "rgba(26, 26, 26, 0.92)",
|
|
193
|
-
borderWidth: 1,
|
|
194
|
-
borderColor: _sharedUi.buoyColors.success + "35",
|
|
195
|
-
borderRadius: 12,
|
|
196
|
-
paddingVertical: 5,
|
|
197
|
-
paddingHorizontal: 10,
|
|
198
|
-
gap: 5,
|
|
199
|
-
zIndex: 9999,
|
|
200
|
-
shadowColor: "#000",
|
|
201
|
-
shadowOffset: {
|
|
202
|
-
width: 0,
|
|
203
|
-
height: 2
|
|
204
|
-
},
|
|
205
|
-
shadowOpacity: 0.2,
|
|
206
|
-
shadowRadius: 6,
|
|
207
|
-
elevation: 4
|
|
208
|
-
},
|
|
209
|
-
minimalDot: {
|
|
210
|
-
width: 6,
|
|
211
|
-
height: 6,
|
|
212
|
-
borderRadius: 3,
|
|
213
|
-
backgroundColor: _sharedUi.buoyColors.success
|
|
214
|
-
},
|
|
215
|
-
minimalText: {
|
|
216
|
-
fontSize: 10,
|
|
217
|
-
fontWeight: "700",
|
|
218
|
-
color: _sharedUi.buoyColors.success,
|
|
219
|
-
letterSpacing: 0.5
|
|
220
|
-
}
|
|
221
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ImpersonateBanner=ImpersonateBanner;exports.ImpersonateBannerMinimal=ImpersonateBannerMinimal;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _impersonateStore=require("../utils/impersonateStore");var _UserAvatar=require("./UserAvatar");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(n,a){if("function"==typeof WeakMap)var l=new WeakMap,i=new WeakMap;return(_interopRequireWildcard=function(e,c){if(!c&&e&&e.__esModule)return e;var t,o,r={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return r;if(t=c?i:l){if(t.has(e))return t.get(e);t.set(e,r)}for(const s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((o=(t=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,s))&&(o.get||o.set)?t(r,s,o):r[s]=e[s]);return r})(n,a)}function ImpersonateBanner({onPress:n,onStopPress:a,position:l="top",offset:i=50}){const e=(0,_react.useSyncExternalStore)(_impersonateStore.impersonateStore.subscribe,_impersonateStore.impersonateStore.getSnapshot,_impersonateStore.impersonateStore.getSnapshot);if(!e.isActive||!e.currentUser||!e.showBanner){return null}const c=async()=>{console.log("[impersonate] banner pause/resume pressed");if(e.isPaused){await _impersonateStore.impersonateStore.resumeImpersonation()}else{await _impersonateStore.impersonateStore.pauseImpersonation()}};const t=e.currentUser.displayName||e.currentUser.email||e.currentUser.id;const o=l==="top"?{top:i}:{bottom:i};const r=async()=>{console.log("[impersonate] banner STOP pressed");await _impersonateStore.impersonateStore.stopImpersonation()};return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.container,o],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.banner,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.userSection,onPress:n,activeOpacity:.7,children:[(0,_jsxRuntime.jsx)(_UserAvatar.UserAvatar,{userId:e.currentUser.id,name:t,size:"small",showActiveIndicator:false}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.userName,e.isPaused&&styles.userNamePaused],numberOfLines:1,children:t})]}),(0,_jsxRuntime.jsx)(_sharedUi.PowerToggleButton,{isEnabled:!e.isPaused,onToggle:c,size:"small",accessibilityLabel:"Toggle impersonation"}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.closeButton,onPress:r,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_sharedUi.X,{size:12,color:"rgba(255, 255, 255, 0.5)"})})]})})}function ImpersonateBannerMinimal({onPress:n}){const a=(0,_react.useSyncExternalStore)(_impersonateStore.impersonateStore.subscribe,_impersonateStore.impersonateStore.getSnapshot,_impersonateStore.impersonateStore.getSnapshot);if(!a.isActive||!a.currentUser){return null}return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.minimalBanner,onPress:n,activeOpacity:.8,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.minimalDot}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.minimalText,children:"IMP"})]})}const styles=_reactNative.StyleSheet.create({container:{position:"absolute",left:0,right:0,alignItems:"center",zIndex:9999,pointerEvents:"box-none"},banner:{flexDirection:"row",alignItems:"center",backgroundColor:"rgba(20, 20, 20, 0.94)",borderWidth:1,borderColor:_sharedUi.buoyColors.success+"40",borderRadius:22,paddingVertical:7,paddingLeft:7,paddingRight:10,gap:10,marginTop:3,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.3,shadowRadius:14,elevation:10},userSection:{flexDirection:"row",alignItems:"center",gap:10},userName:{fontSize:14,fontWeight:"600",color:"#fff",maxWidth:180},userNamePaused:{opacity:.6},closeButton:{width:22,height:22,borderRadius:11,backgroundColor:"rgba(128, 128, 128, 0.16)",alignItems:"center",justifyContent:"center",marginLeft:-4},minimalBanner:{position:"absolute",top:60,right:16,flexDirection:"row",alignItems:"center",backgroundColor:"rgba(26, 26, 26, 0.92)",borderWidth:1,borderColor:_sharedUi.buoyColors.success+"35",borderRadius:12,paddingVertical:5,paddingHorizontal:10,gap:5,zIndex:9999,shadowColor:"#000",shadowOffset:{width:0,height:2},shadowOpacity:.2,shadowRadius:6,elevation:4},minimalDot:{width:6,height:6,borderRadius:3,backgroundColor:_sharedUi.buoyColors.success},minimalText:{fontSize:10,fontWeight:"700",color:_sharedUi.buoyColors.success,letterSpacing:.5}});
|
|
@@ -1,181 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ImpersonateHistoryList = ImpersonateHistoryList;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
10
|
-
var _UserCard = require("./UserCard");
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
-
/**
|
|
14
|
-
* ImpersonateHistoryList Component
|
|
15
|
-
*
|
|
16
|
-
* List of recently impersonated users for quick switching.
|
|
17
|
-
* Uses polished UserCard component for consistent styling.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/** Wrapper to use the useRelativeTime hook per history item */
|
|
21
|
-
function HistoryItemCard({
|
|
22
|
-
item,
|
|
23
|
-
isActive,
|
|
24
|
-
onSelect,
|
|
25
|
-
onStop,
|
|
26
|
-
onRemove,
|
|
27
|
-
showRemoveButton
|
|
28
|
-
}) {
|
|
29
|
-
const lastUsedTime = (0, _sharedUi.useRelativeTime)(new Date(item.lastUsedAt));
|
|
30
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_UserCard.UserCard, {
|
|
31
|
-
user: item.user,
|
|
32
|
-
isActive: isActive,
|
|
33
|
-
onPress: () => !isActive && onSelect(item.user),
|
|
34
|
-
onStop: isActive ? onStop : undefined,
|
|
35
|
-
onRemove: onRemove,
|
|
36
|
-
showRemoveButton: showRemoveButton,
|
|
37
|
-
lastUsedTime: lastUsedTime
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
function ImpersonateHistoryList({
|
|
41
|
-
history,
|
|
42
|
-
currentUserId,
|
|
43
|
-
onSelectUser,
|
|
44
|
-
onStopImpersonation,
|
|
45
|
-
onRemoveFromHistory,
|
|
46
|
-
onClearHistory
|
|
47
|
-
}) {
|
|
48
|
-
const renderHistoryItem = (0, _react.useCallback)(({
|
|
49
|
-
item
|
|
50
|
-
}) => {
|
|
51
|
-
const isActive = currentUserId === item.user.id;
|
|
52
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(HistoryItemCard, {
|
|
53
|
-
item: item,
|
|
54
|
-
isActive: isActive,
|
|
55
|
-
onSelect: onSelectUser,
|
|
56
|
-
onStop: onStopImpersonation,
|
|
57
|
-
onRemove: onRemoveFromHistory ? () => onRemoveFromHistory(item.user.id) : undefined,
|
|
58
|
-
showRemoveButton: !!onRemoveFromHistory
|
|
59
|
-
});
|
|
60
|
-
}, [currentUserId, onSelectUser, onStopImpersonation, onRemoveFromHistory]);
|
|
61
|
-
if (history.length === 0) {
|
|
62
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.ToolEmptyState, {
|
|
63
|
-
testID: "buoy-impersonate-history-empty"
|
|
64
|
-
// disguise = "impersonating another user" — the tool's own state,
|
|
65
|
-
// with nothing worn yet.
|
|
66
|
-
,
|
|
67
|
-
otto: "disguise",
|
|
68
|
-
title: "No History",
|
|
69
|
-
message: "Users you impersonate will appear here for quick access"
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
73
|
-
style: styles.container,
|
|
74
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
75
|
-
style: styles.headerRow,
|
|
76
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
77
|
-
style: styles.headerTitle,
|
|
78
|
-
children: "Recent"
|
|
79
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
80
|
-
style: styles.headerBadge,
|
|
81
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
82
|
-
style: styles.headerBadgeText,
|
|
83
|
-
children: history.length
|
|
84
|
-
})
|
|
85
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
86
|
-
style: styles.headerSpacer
|
|
87
|
-
}), onClearHistory && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
|
|
88
|
-
style: styles.clearButton,
|
|
89
|
-
onPress: onClearHistory,
|
|
90
|
-
activeOpacity: 0.7,
|
|
91
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Trash2, {
|
|
92
|
-
size: 12,
|
|
93
|
-
color: _sharedUi.night.color.textTertiary
|
|
94
|
-
})
|
|
95
|
-
})]
|
|
96
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.FlatList, {
|
|
97
|
-
data: history,
|
|
98
|
-
keyExtractor: item => item.user.id,
|
|
99
|
-
renderItem: renderHistoryItem,
|
|
100
|
-
ItemSeparatorComponent: () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
101
|
-
style: styles.separator
|
|
102
|
-
}),
|
|
103
|
-
contentContainerStyle: styles.listContent,
|
|
104
|
-
showsVerticalScrollIndicator: false
|
|
105
|
-
})]
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
const styles = _reactNative.StyleSheet.create({
|
|
109
|
-
container: {
|
|
110
|
-
flex: 1,
|
|
111
|
-
paddingHorizontal: 16
|
|
112
|
-
},
|
|
113
|
-
headerRow: {
|
|
114
|
-
flexDirection: "row",
|
|
115
|
-
alignItems: "center",
|
|
116
|
-
paddingVertical: 10,
|
|
117
|
-
gap: 8
|
|
118
|
-
},
|
|
119
|
-
headerTitle: {
|
|
120
|
-
fontSize: 12,
|
|
121
|
-
fontWeight: "600",
|
|
122
|
-
color: _sharedUi.night.color.textTertiary,
|
|
123
|
-
textTransform: "uppercase",
|
|
124
|
-
letterSpacing: 0.5
|
|
125
|
-
},
|
|
126
|
-
headerBadge: {
|
|
127
|
-
backgroundColor: _sharedUi.night.color.surfaceElevated,
|
|
128
|
-
paddingHorizontal: 6,
|
|
129
|
-
paddingVertical: 2,
|
|
130
|
-
borderRadius: 4
|
|
131
|
-
},
|
|
132
|
-
headerBadgeText: {
|
|
133
|
-
fontSize: 10,
|
|
134
|
-
fontWeight: "600",
|
|
135
|
-
color: _sharedUi.night.color.textTertiary
|
|
136
|
-
},
|
|
137
|
-
headerSpacer: {
|
|
138
|
-
flex: 1
|
|
139
|
-
},
|
|
140
|
-
clearButton: {
|
|
141
|
-
width: 24,
|
|
142
|
-
height: 24,
|
|
143
|
-
alignItems: "center",
|
|
144
|
-
justifyContent: "center",
|
|
145
|
-
backgroundColor: _sharedUi.night.color.surfaceElevated,
|
|
146
|
-
borderRadius: 4
|
|
147
|
-
},
|
|
148
|
-
listContent: {
|
|
149
|
-
paddingBottom: 20
|
|
150
|
-
},
|
|
151
|
-
separator: {
|
|
152
|
-
height: 8
|
|
153
|
-
},
|
|
154
|
-
emptyContainer: {
|
|
155
|
-
flex: 1,
|
|
156
|
-
alignItems: "center",
|
|
157
|
-
justifyContent: "center",
|
|
158
|
-
paddingHorizontal: 32,
|
|
159
|
-
paddingVertical: 48
|
|
160
|
-
},
|
|
161
|
-
emptyIcon: {
|
|
162
|
-
width: 56,
|
|
163
|
-
height: 56,
|
|
164
|
-
borderRadius: 28,
|
|
165
|
-
backgroundColor: _sharedUi.night.color.surfaceElevated,
|
|
166
|
-
alignItems: "center",
|
|
167
|
-
justifyContent: "center",
|
|
168
|
-
marginBottom: 16
|
|
169
|
-
},
|
|
170
|
-
emptyTitle: {
|
|
171
|
-
fontSize: 16,
|
|
172
|
-
fontWeight: "600",
|
|
173
|
-
color: _sharedUi.night.color.text,
|
|
174
|
-
marginBottom: 6
|
|
175
|
-
},
|
|
176
|
-
emptyDescription: {
|
|
177
|
-
fontSize: 14,
|
|
178
|
-
color: _sharedUi.night.color.textSecondary,
|
|
179
|
-
textAlign: "center"
|
|
180
|
-
}
|
|
181
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ImpersonateHistoryList=ImpersonateHistoryList;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _UserCard=require("./UserCard");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(n,o){if("function"==typeof WeakMap)var s=new WeakMap,l=new WeakMap;return(_interopRequireWildcard=function(e,i){if(!i&&e&&e.__esModule)return e;var t,r,a={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return a;if(t=i?l:s){if(t.has(e))return t.get(e);t.set(e,a)}for(const c in e)"default"!==c&&{}.hasOwnProperty.call(e,c)&&((r=(t=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,c))&&(r.get||r.set)?t(a,c,r):a[c]=e[c]);return a})(n,o)}function HistoryItemCard({item:n,isActive:o,onSelect:s,onStop:l,onRemove:e,showRemoveButton:i}){const t=(0,_sharedUi.useRelativeTime)(new Date(n.lastUsedAt));return(0,_jsxRuntime.jsx)(_UserCard.UserCard,{user:n.user,isActive:o,onPress:()=>!o&&s(n.user),onStop:o?l:void 0,onRemove:e,showRemoveButton:i,lastUsedTime:t})}function ImpersonateHistoryList({history:n,currentUserId:o,onSelectUser:s,onStopImpersonation:l,onRemoveFromHistory:e,onClearHistory:i}){const t=(0,_react.useCallback)(({item:r})=>{const a=o===r.user.id;return(0,_jsxRuntime.jsx)(HistoryItemCard,{item:r,isActive:a,onSelect:s,onStop:l,onRemove:e?()=>e(r.user.id):void 0,showRemoveButton:!!e})},[o,s,l,e]);if(n.length===0){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:"buoy-impersonate-history-empty",otto:"disguise",title:"No History",message:"Users you impersonate will appear here for quick access"})}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.headerRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.headerTitle,children:"Recent"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.headerBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.headerBadgeText,children:n.length})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.headerSpacer}),i&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.clearButton,onPress:i,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:12,color:_sharedUi.night.color.textTertiary})})]}),(0,_jsxRuntime.jsx)(_reactNative.FlatList,{data:n,keyExtractor:r=>r.user.id,renderItem:t,ItemSeparatorComponent:()=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}),contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:false})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1,paddingHorizontal:16},headerRow:{flexDirection:"row",alignItems:"center",paddingVertical:10,gap:8},headerTitle:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5},headerBadge:{backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:6,paddingVertical:2,borderRadius:4},headerBadgeText:{fontSize:10,fontWeight:"600",color:_sharedUi.night.color.textTertiary},headerSpacer:{flex:1},clearButton:{width:24,height:24,alignItems:"center",justifyContent:"center",backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:4},listContent:{paddingBottom:20},separator:{height:8},emptyContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:32,paddingVertical:48},emptyIcon:{width:56,height:56,borderRadius:28,backgroundColor:_sharedUi.night.color.surfaceElevated,alignItems:"center",justifyContent:"center",marginBottom:16},emptyTitle:{fontSize:16,fontWeight:"600",color:_sharedUi.night.color.text,marginBottom:6},emptyDescription:{fontSize:14,color:_sharedUi.night.color.textSecondary,textAlign:"center"}});
|