@clerk/clerk-js
Version:
Clerk JS library
1 lines • 9.49 kB
JavaScript
;(globalThis.webpackChunk_clerk_clerk_js=globalThis.webpackChunk_clerk_clerk_js||[]).push([["192"],{88493:function(e,t,l){l.d(t,{l:()=>_}),l(56113),l(65223),l(13189),l(63277),l(82230),l(27899),l(37389),l(27968),l(46299);var i=l(79109),r=l(73531),n=l(83799),a=l(69144),o=l(2672),s=l(70431),d=l(19460),c=l(96443),u=l(88870),p=l(86842),m=l(36788),h=l(11576),g=l(64204),v=l(93266),b=l(17703),f=l(51217),x=l(90408);let Z=e=>/^\S+@\S+\.\S+$/.test(e),_=e=>{let{onSuccess:t,onReset:l,resetButtonLabel:h}=e,{organization:v,invitations:x}=(0,n.o8)({invitations:{pageSize:10,keepPreviousData:!0}}),_=(0,o.useCardState)(),{t:y,locale:C}=(0,b.zJ)(),[T,w]=(0,a.useState)(!1),k=(0,m.Yp)("emailAddress","",{type:"text",label:(0,b.u1)("formFieldLabel__emailAddresses")}),P=S(),$=(0,m.Yp)("role","",{label:(0,b.u1)("formFieldLabel__role")});if((0,a.useEffect)(()=>{!$.value&&P&&$.setValue(P)},[P,$]),!v)return null;let{props:{setError:B,setWarning:A,setSuccess:F,setInfo:D,isFocused:K,validatePassword:R,setHasPassedComplexity:X,hasPassedComplexity:E,feedback:I,feedbackType:M,clearFeedback:L,...j}}=k,W=(!!k.value.length||T)&&!!$.value;return(0,i.BX)(s.l.Root,{onSubmit:e=>{if(e.preventDefault(),!W)return;let l=new FormData(e.currentTarget);return v.inviteMembers({emailAddresses:k.value.split(","),role:l.get("role")}).then(async()=>{var e;return await (null==x||null==(e=x.revalidate)?void 0:e.call(x)),null==t?void 0:t()}).catch(e=>{var t,l,i,n,a;if(!(0,r.kD)(e))return void(0,u.S3)(e,[],_.setError);switch((e=>{var t,l,i,r;let n=new Set([...null!=(i=null==(t=e.meta)?void 0:t.emailAddresses)?i:[],...null!=(r=null==(l=e.meta)?void 0:l.identifiers)?r:[]]),a=k.value.split(",");k.setValue(a.filter(e=>!n.has(e)).join(","))})(e.errors[0]),null==(l=e.errors)||null==(t=l[0])?void 0:t.code){case"duplicate_record":{let t=(null==(i=e.errors[0].meta)?void 0:i.emailAddresses)||[];_.setError(y((0,b.u1)("organizationProfile.invitePage.detailsTitle__inviteFailed",{email_addresses:(0,p.z$)(t,C)})));break}case"already_a_member_in_organization":{let t=null==(n=(null!=(a=e.errors[0].longMessage)?a:"").match(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/))?void 0:n[0];(0,u.S3)(e,[],e=>t?_.setError(y((0,b.u1)("unstable__errors.already_a_member_in_organization",{email:t}))):_.setError(e));break}default:(0,u.S3)(e,[],_.setError)}})},children:[(0,i.tZ)(s.l.ControlRow,{elementId:k.id,children:(0,i.tZ)(c.E,{...j,autoFocus:!0,validate:Z,sx:{width:"100%"},validateUnsubmittedEmail:e=>w(Z(e)),placeholder:(0,b.u1)("formFieldInputPlaceholder__emailAddresses")})}),(0,i.BX)(g.Flex,{align:"center",justify:"between",sx:e=>({marginTop:e.space.$2,gap:e.space.$4,flexWrap:"wrap",[f.mqu.sm]:{justifyContent:"center"}}),children:[(0,i.tZ)(z,{...$}),(0,i.BX)(d.K,{sx:e=>({margin:e.space.$none,flexWrap:"wrap",justifyContent:"center"}),children:[(0,i.tZ)(s.l.SubmitButton,{block:!1,isDisabled:!W,localizationKey:(0,b.u1)("organizationProfile.invitePage.formButtonPrimary__continue")}),(0,i.tZ)(s.l.ResetButton,{localizationKey:h||(0,b.u1)("userProfile.formButtonReset"),block:!1,onClick:l})]})]})]})},z=e=>{let{options:t,isLoading:l}=(0,v.e)(),{t:r}=(0,b.zJ)();return(0,i.tZ)(s.l.ControlRow,{elementId:e.id,children:(0,i.tZ)(g.Flex,{direction:"col",gap:2,children:(0,i.tZ)(x.DQ,{...e.props,roles:t,isDisabled:l,onChange:t=>e.setValue(t),triggerSx:e=>({minWidth:e.sizes.$40,justifyContent:"space-between",display:"flex"}),optionListSx:e=>({minWidth:e.sizes.$48}),prefixLocalizationKey:"".concat(r((0,b.u1)("formFieldLabel__role")),":")})})})},S=()=>{let{options:e}=(0,v.e)(),{organizationSettings:t}=(0,h.useEnvironment)(),l=t.domains.defaultRole;return l||(null==e?void 0:e.length)!==1||(l=e[0].value),l}},45727:function(e,t,l){l.d(t,{a:()=>x,N:()=>f});var i=l(79109),r=l(83799),n=l(2672),a=l(68487),o=l(19566),s=l(67263),d=l(93344),c=l(8969),u=l(11576),p=l(64204),m=l(44709),h=l(96519),g=l(24676);let v=e=>{let{__unstable_manageBillingUrl:t,__unstable_manageBillingMembersLimit:l}=e,r=(0,g.useRouter)();return(0,i.BX)(p.Flex,{sx:e=>({background:e.colors.$neutralAlpha50,padding:e.space.$4,borderRadius:e.radii.$md}),children:[(0,i.tZ)(p.AlertIcon,{variant:"warning",colorScheme:"danger",sx:e=>({marginTop:e.space.$1})}),(0,i.BX)(p.Text,{children:["This organization is limited to ",(0,d.OR)(l)," members.",(0,i.tZ)("br",{}),(0,i.tZ)(p.Link,{sx:e=>({alignSelf:"flex-start",color:e.colors.$primary500,fontWeight:e.fontWeights.$normal}),onClick:()=>r.navigate((0,d.OR)(t)),children:"Upgrade for unlimited members"})]})]})};var b=l(88493);let f=(0,n.withCardStateProvider)(e=>{let{close:t}=(0,m.XC)(),{onReset:l=t}=e,o=(0,p.localizationKeys)("organizationProfile.invitePage.title"),h=(0,p.localizationKeys)("organizationProfile.invitePage.subtitle"),g=(0,n.useCardState)(),f=(0,c.a2)({onNextStep:()=>g.setError(void 0)}),{organization:Z}=(0,r.o8)(),{__unstable_manageBillingUrl:_,__unstable_manageBillingMembersLimit:z}=(0,u.useOrganizationProfileContext)();if(!Z)return null;let S=!!z&&(0,d.OR)(z)<=Z.pendingInvitationsCount+Z.membersCount;return(0,i.BX)(c.en,{...f.props,children:[(0,i.BX)(a.Y,{headerTitle:o,headerSubtitle:h,children:[S&&_&&(0,i.tZ)(v,{__unstable_manageBillingUrl:_,__unstable_manageBillingMembersLimit:z}),(0,i.tZ)(b.l,{onSuccess:f.nextStep,onReset:l})]}),(0,i.tZ)(s.I,{title:o,onFinish:t,contents:(0,i.tZ)(x,{})})]})}),x=()=>(0,i.BX)(p.Flex,{direction:"col",center:!0,gap:4,children:[(0,i.tZ)(o.f,{boxElementDescriptor:p.descriptors.invitationsSentIconBox,iconElementDescriptor:p.descriptors.invitationsSentIcon,icon:h.GT}),(0,i.tZ)(p.Text,{localizationKey:(0,p.localizationKeys)("organizationProfile.invitePage.successMessage")})]})},90408:function(e,t,l){l.d(t,{DQ:()=>p,RN:()=>u,wQ:()=>d}),l(65223);var i=l(79109),r=l(69144),n=l(77691),a=l(3146),o=l(64204),s=l(93266);let d=e=>{let{headers:t,page:l,onPageChange:r,rows:a,isLoading:s,itemCount:d,itemsPerPage:u,pageCount:p,emptyStateLocalizationKey:m}=e,h=d>0?Math.max(0,(l-1)*u)+1:0,g=Math.min(l*u,d);return(0,i.BX)(o.Col,{gap:4,sx:{width:"100%"},children:[(0,i.tZ)(o.Flex,{sx:e=>({overflowX:"auto",padding:e.space.$1}),children:(0,i.BX)(o.Table,{children:[(0,i.tZ)(o.Thead,{children:(0,i.tZ)(o.Tr,{children:t.map((e,t)=>(0,i.tZ)(o.Th,{elementDescriptor:o.descriptors.tableHead,localizationKey:e},t))})}),(0,i.tZ)(o.Tbody,{children:s?(0,i.tZ)(o.Tr,{children:(0,i.tZ)(o.Td,{colSpan:4,children:(0,i.tZ)(o.Spinner,{colorScheme:"primary",sx:{margin:"auto",display:"block"},elementDescriptor:o.descriptors.spinner})})}):a.length?a:(0,i.tZ)(c,{localizationKey:m},"empty")})]})}),p>1&&(0,i.tZ)(n.t,{count:p,page:l,onChange:r,siblingCount:1,rowInfo:{allRowsCount:d,startingRow:h,endingRow:g}})]})},c=e=>(0,i.tZ)(o.Tr,{children:(0,i.tZ)(o.Td,{colSpan:4,children:(0,i.tZ)(o.Text,{localizationKey:e.localizationKey,sx:{margin:"auto",display:"block",width:"fit-content"}})})}),u=e=>(0,i.tZ)(o.Tr,{...e,sx:e=>({":hover":{backgroundColor:e.colors.$neutralAlpha50}})}),p=e=>{let{value:t,fallbackLabel:l,roles:n,onChange:d,isDisabled:c,triggerSx:u,optionListSx:p,prefixLocalizationKey:h}=e,{localizeCustomRole:g}=(0,s.q)(),v=(0,r.useMemo)(()=>[...n||[]],[n]),b=(0,r.useMemo)(()=>v.find(e=>e.value===t),[v,t]),{t:f}=(0,o.useLocalizations)(),x=(0,r.useMemo)(()=>v.map(e=>({value:e.value,label:g(e.value)||e.label})),[v,g]);return(0,i.BX)(a.Ph,{elementId:"role",options:x,value:t,placeholder:f((0,o.localizationKeys)("organizationProfile.invitePage.selectDropdown__role")),onChange:e=>d(e.value),renderOption:(e,t,l)=>(0,i.tZ)(m,{isSelected:l,option:e,sx:e=>({"&:hover":{backgroundColor:e.colors.$neutralAlpha100},'&[data-focused="true"]':{backgroundColor:e.colors.$neutralAlpha150}})}),children:[(0,i.tZ)("input",{name:"role",type:"hidden",value:t}),(0,i.tZ)(a.UN,{sx:u||(e=>({color:e.colors.$colorForeground,backgroundColor:"transparent",textWrap:"nowrap"})),isDisabled:c||!!t&&v.length>0&&!b,children:(null==b?void 0:b.label)||(null==b?void 0:b.value)?(0,i.BX)(o.Flex,{as:"span",gap:1,children:[h&&(0,i.tZ)(o.Text,{as:"span",colorScheme:"secondary",localizationKey:h}),(0,i.tZ)(o.Text,{as:"span",colorScheme:"body",children:g(null==b?void 0:b.value)||(null==b?void 0:b.label)})]}):l?(0,i.tZ)(o.Text,{as:"span",colorScheme:"body",children:l}):null}),(0,i.tZ)(a.pp,{sx:p})]})},m=(0,r.memo)(e=>{let{option:t,isSelected:l,sx:r,...n}=e;return(0,i.tZ)(o.Flex,{sx:[e=>({width:"100%",padding:"".concat(e.space.$2," ").concat(e.space.$4),borderRadius:e.radii.$md}),r],...n,children:(0,i.tZ)(o.Text,{colorScheme:"secondary",children:null==t?void 0:t.label})})})},8181:function(e,t,l){l.d(t,{D:()=>s});var i=l(79109),r=l(6654),n=l(25623),a=l(64204),o=l(17703);let s=e=>{let{organization:t,...l}=e;return(0,i.BX)(a.Col,{elementDescriptor:a.descriptors.organizationAvatarUploaderContainer,children:[(0,i.tZ)(a.Text,{variant:"subtitle",sx:e=>({textAlign:"left",marginBottom:e.space.$2}),localizationKey:(0,o.u1)("organizationProfile.start.profileSection.uploadAction__title")}),(0,i.tZ)(r.C,{...l,title:(0,o.u1)("userProfile.profilePage.imageFormTitle"),avatarPreview:(0,i.tZ)(n.l,{size:e=>e.sizes.$16,...t})})]})}},57484:function(e,t,l){l.d(t,{AO:()=>i,Sz:()=>r});let i={userMemberships:{infinite:!0},userInvitations:{infinite:!0},userSuggestions:{infinite:!0,status:["pending","accepted"]}},r=(e,t,l)=>{var i;if(void 0===t)return[{data:[e],total_count:1}];let r=(null==t||null==(i=t[t.length-1])?void 0:i.total_count)||1;return t.map(t=>{if(void 0===t)return t;let i=t.data.map(t=>t.id===e.id?{...e}:t);return{...t,data:i,total_count:"negative"===l?r-1:r}})}}}]);