@clerk/clerk-js
Version:
Clerk JS library
1 lines • 4.14 kB
JavaScript
;(globalThis.webpackChunk_clerk_clerk_js=globalThis.webpackChunk_clerk_clerk_js||[]).push([["378"],{75692:function(e,t,o){o.r(t),o.d(t,{ImpersonationFab:()=>w});var n=o(79109),i=o(83799),r=o(69144),a=o(95878),s=o(11576),c=o(64204),l=o(37348),d=o(54264),p=o(96519),m=o(51217);let u=e=>{let{width:t,height:o,...i}=e,{sx:r,...a}=i;return(0,n.tZ)(c.Col,{elementDescriptor:c.descriptors.impersonationFabIconContainer,center:!0,sx:[e=>({width:t,height:o,backgroundColor:e.colors.$danger500,borderRadius:e.radii.$circle}),r],...a,children:(0,n.tZ)(c.Icon,{elementDescriptor:c.descriptors.impersonationFabIcon,icon:p.bA,sx:e=>({color:e.colors.$white}),size:"lg"})})},h=e=>{let{title:t,signOutText:o}=e,{session:r}=(0,i.kP)(),{user:a}=(0,i.aF)(),{signOut:l}=(0,i.cL)(),{otherSessions:p}=(0,d.j)({user:a}),{navigateAfterSignOut:m,navigateAfterMultiSessionSingleSignOutUrl:u}=(0,s.useSignOutContext)();return(0,n.BX)(c.Col,{sx:e=>({width:"100%",paddingLeft:e.sizes.$4,paddingRight:e.sizes.$6,whiteSpace:"nowrap"}),children:[(0,n.tZ)(c.Text,{colorScheme:"secondary",elementDescriptor:c.descriptors.impersonationFabTitle,variant:"buttonLarge",truncate:!0,localizationKey:t}),(0,n.tZ)(c.Link,{variant:"buttonLarge",elementDescriptor:c.descriptors.impersonationFabActionLink,sx:e=>({alignSelf:"flex-start",color:e.colors.$primary500,":hover":{cursor:"pointer"}}),localizationKey:o,onClick:()=>0===p.length?l(m):l(u,{sessionId:r.id})})]})},f=()=>{let{session:e}=(0,i.kP)(),{t}=(0,c.useLocalizations)(),{parsedInternalTheme:o}=(0,c.useAppearance)(),s=(0,r.useRef)(null),d=null==e?void 0:e.actor,p=o.sizes.$16,f="--cl-impersonation-fab-top",w="--cl-impersonation-fab-right",x=()=>{let e=s.current;if(!e)return;let t=window.innerWidth-e.offsetLeft-e.offsetWidth,o=window.innerHeight-e.offsetTop-e.offsetHeight;[e.offsetLeft,t,e.offsetTop,o].some(e=>e<0)&&(document.documentElement.style.setProperty(w,"".concat(23,"px")),document.documentElement.style.setProperty(f,"".concat(109,"px")))},g=r.useCallback(e=>{e.stopPropagation(),e.preventDefault();let t=s.current;if(!t)return;let o="".concat(window.innerWidth-t.offsetLeft-t.offsetWidth-e.movementX,"px");document.documentElement.style.setProperty(w,o),document.documentElement.style.setProperty(f,"".concat(t.offsetTop- -e.movementY,"px"))},[]);if((0,r.useEffect)(()=>(window.addEventListener("resize",x),()=>{window.removeEventListener("resize",x)}),[]),!d||!e.user)return null;let b=(0,c.localizationKeys)("impersonationFab.title",{identifier:(0,a.Pp)(e.user)||(0,a.xC)(e.user)}),v=t(b).length;return(0,n.tZ)(l.h,{children:(0,n.BX)(c.Flex,{ref:s,elementDescriptor:c.descriptors.impersonationFab,onPointerDown:()=>{window.addEventListener("pointermove",g),window.addEventListener("pointerup",()=>{window.removeEventListener("pointermove",g),x()},{once:!0})},align:"center",sx:e=>({touchAction:"none",position:"fixed",overflow:"hidden",top:"var(".concat(f,", ").concat(109,"px)"),right:"var(".concat(w,", ").concat(23,"px)"),zIndex:e.zIndices.$fab,boxShadow:e.shadows.$fabShadow,borderRadius:e.radii.$halfHeight,backgroundColor:e.colors.$white,fontFamily:e.fonts.$main,":hover":{cursor:"grab"},":hover #cl-impersonationText":{transition:"max-width ".concat(e.transitionDuration.$slowest," ease, opacity ").concat(e.transitionDuration.$slower," ease ").concat(e.transitionDuration.$slowest),maxWidth:"min(calc(50vw - ".concat(p," - 2 * ").concat(23,"px), ").concat(v,"ch)"),[m.mqu.md]:{maxWidth:"min(calc(100vw - ".concat(p," - 2 * ").concat(23,"px), ").concat(v,"ch)")},opacity:1},":hover #cl-impersonationEye":{transform:"rotate(-180deg)"}}),children:[(0,n.tZ)(u,{id:"cl-impersonationEye",width:p,height:p,sx:e=>({transition:"transform ".concat(e.transitionDuration.$slowest," ease")})}),(0,n.tZ)(c.Flex,{id:"cl-impersonationText",sx:e=>({transition:"max-width ".concat(e.transitionDuration.$slowest," ease, opacity ").concat(e.transitionDuration.$fast," ease"),maxWidth:"0px",opacity:0}),children:(0,n.tZ)(h,{title:b,signOutText:(0,c.localizationKeys)("impersonationFab.action__signOut")})})]})})},w=(0,s.withCoreUserGuard)(()=>(0,n.tZ)(m.InternalThemeProvider,{children:(0,n.tZ)(f,{})}))}}]);