@wacht/jsx 0.0.1-alpha.16 → 0.0.1-alpha.17

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/dist/index.cjs.js CHANGED
@@ -4801,7 +4801,7 @@ cursor: pointer;
4801
4801
  margin: 0 auto;
4802
4802
  padding: 6px 16px;
4803
4803
  font-size: 13px;
4804
- `,nv=()=>{var R,E;const{organizationMemberships:t,refetch:r,loading:o}=bt(),{workspaces:n}=yt(),{switchOrganization:a,switchWorkspace:s}=Fe(),{deployment:p}=ve(),[g,c]=i.useState(null),[h,d]=i.useState("orgList"),[l,m]=i.useState(null),x=(p==null?void 0:p.b2b_settings.workspaces_enabled)??!1,v=(p==null?void 0:p.b2b_settings.allow_users_to_create_orgs)??!1,w=i.useRef(!1);i.useEffect(()=>{if(!(w.current||!t)){if(w.current=!0,t.length===0){d("createOrg");return}if(!x){d("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),d("createWorkspace");return}d("orgList")}},[t,n,x]),console.log("view mode",h,x);const C=T=>T.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2),$=async T=>{if(x){m(T.id),d("workspaceList");return}c(T.id);try{await a(T.id)}finally{c(null)}},y=async T=>{c(T.id);try{await s(T.id)}finally{c(null)}},z=async T=>{await r(),x&&T&&(m(T.id),d("createWorkspace"))},_=()=>{},k=async()=>{m(null),d("orgList")},b=(R=t==null?void 0:t.find(T=>T.organization.id===l))==null?void 0:R.organization,f=l?n==null?void 0:n.filter(T=>T.organization.id===l):[];if(o)return null;if(h==="createOrg")return e.jsx(we.Body,{style:{padding:0},children:e.jsx(rn,{onSuccess:z,onCancel:t&&t.length>0?()=>d("orgList"):void 0})});if(h==="createWorkspace"&&l)return e.jsx(we.Body,{style:{padding:0},children:e.jsx(_a,{organizationId:l,onSuccess:_,onCancel:()=>d("workspaceList"),onCreateOrganization:()=>d("createOrg")})});const I=h==="workspaceList",j=I?"Select a workspace":"Select an organization",S=I?`Choose a workspace in ${(b==null?void 0:b.name)||""}`:`to continue to ${((E=p==null?void 0:p.ui_settings)==null?void 0:E.app_name)||"App"}`;return e.jsxs(q1,{children:[e.jsxs(Y1,{children:[e.jsxs("div",{children:[e.jsx(Ae,{}),e.jsxs(ev,{children:[e.jsx(tv,{children:j}),e.jsx(rv,{children:S})]})]}),e.jsx($a,{showName:!0})]}),e.jsxs(Z1,{children:[e.jsxs(K1,{children:[e.jsxs(Q1,{children:[e.jsx(X1,{children:I?"Workspaces":"Your organizations"}),I&&e.jsxs(J1,{onClick:k,children:[e.jsx(Ur,{}),"Go back"]})]}),e.jsx(ov,{children:I?e.jsx(e.Fragment,{children:f&&f.length>0?f.map(T=>{var O,D,M;const P=((O=T.eligibility_restriction)==null?void 0:O.type)!=="none"&&((D=T.eligibility_restriction)==null?void 0:D.type)!==void 0;return e.jsxs($i,{onClick:()=>!P&&y(T),disabled:g===T.id||P,style:{opacity:P?.7:1},children:[e.jsx(zi,{children:T.image_url?e.jsx(Ei,{src:T.image_url,alt:T.name}):C(T.name).charAt(0)}),e.jsxs(Pi,{children:[e.jsx(Ri,{children:T.name}),e.jsxs(Ii,{children:[e.jsx(Lo,{}),"Workspace"]})]}),e.jsx(Ti,{children:e.jsx(ua,{})}),P&&e.jsxs(Oi,{children:[e.jsx(ut,{size:14}),(M=T.eligibility_restriction)==null?void 0:M.message]})]},T.id)}):e.jsxs(Mi,{children:[e.jsx(Li,{children:"No workspaces yet"}),e.jsxs(Ai,{children:["Create your first workspace for"," ",(b==null?void 0:b.name)||"this organization"]}),e.jsxs(Di,{onClick:()=>d("createWorkspace"),children:[e.jsx(Je,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(T=>{var re,X,U;const P=T.organization,O=n==null?void 0:n.filter(Z=>Z.organization.id===P.id),D=(O==null?void 0:O.length)||0,M=P.member_count,N=T.roles[0].name,F=T.roles.length-1,J=F>0?`${N.charAt(0).toUpperCase()+N.slice(1)} +${F}`:N.charAt(0).toUpperCase()+N.slice(1),ie=((re=T.eligibility_restriction)==null?void 0:re.type)!=="none"&&((X=T.eligibility_restriction)==null?void 0:X.type)!==void 0;return e.jsxs($i,{onClick:()=>!ie&&$(P),disabled:g===P.id||ie,style:{opacity:ie?.7:1},children:[e.jsx(zi,{children:P.image_url?e.jsx(Ei,{src:P.image_url,alt:P.name}):C(P.name)}),e.jsxs(Pi,{children:[e.jsx(Ri,{children:P.name}),e.jsx(Ii,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Lo,{}),D," workspace",D!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(rh,{}),J," • ",M," member",M!==1?"s":""]})})]}),e.jsx(Ti,{children:e.jsx(ua,{})}),ie&&e.jsxs(Oi,{children:[e.jsx(ut,{size:14}),(U=T.eligibility_restriction)==null?void 0:U.message]})]},P.id)}):e.jsxs(Mi,{children:[e.jsx(Li,{children:"No organizations yet"}),e.jsx(Ai,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(Di,{onClick:()=>d("createOrg"),children:[e.jsx(Je,{}),"Create organization"]})]})})]}),I&&f&&f.length>0&&e.jsxs(K,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createWorkspace"),disabled:g!==null,children:[e.jsx(Je,{size:12}),"Create new workspace"]}),!I&&t&&t.length>0&&v&&e.jsxs(K,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createOrg"),disabled:g!==null,children:[e.jsx(Je,{size:12}),"Create new organization"]})]})]})},av=u(we.Content)`
4804
+ `,nv=()=>{var R,E;const{organizationMemberships:t,refetch:r,loading:o}=bt(),{workspaces:n}=yt(),{switchOrganization:a,switchWorkspace:s}=Fe(),{deployment:p}=ve(),[g,c]=i.useState(null),[h,d]=i.useState("orgList"),[l,m]=i.useState(null),x=(p==null?void 0:p.b2b_settings.workspaces_enabled)??!1,v=(p==null?void 0:p.b2b_settings.allow_users_to_create_orgs)??!1,w=i.useRef(!1);i.useEffect(()=>{if(!(w.current||!t)){if(w.current=!0,t.length===0){d("createOrg");return}if(!x){d("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),d("createWorkspace");return}d("orgList")}},[t,n,x]),console.log("view mode",h,x);const C=T=>T.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2),$=async T=>{if(x){m(T.id),d("workspaceList");return}c(T.id);try{await a(T.id)}finally{c(null)}},y=async T=>{c(T.id);try{await s(T.id)}finally{c(null)}},z=async T=>{await r(),x&&T&&(m(T.id),d("createWorkspace"))},_=()=>{},k=async()=>{m(null),d("orgList")},b=(R=t==null?void 0:t.find(T=>T.organization.id===l))==null?void 0:R.organization,f=l?n==null?void 0:n.filter(T=>T.organization.id===l):[];if(o)return null;if(h==="createOrg")return e.jsx(we.Body,{style:{padding:0},children:e.jsx(rn,{onSuccess:z,onCancel:()=>d("orgList")})});if(h==="createWorkspace"&&l)return e.jsx(we.Body,{style:{padding:0},children:e.jsx(_a,{organizationId:l,onSuccess:_,onCancel:()=>d("workspaceList"),onCreateOrganization:()=>d("createOrg")})});const I=h==="workspaceList",j=I?"Select a workspace":"Select an organization",S=I?`Choose a workspace in ${(b==null?void 0:b.name)||""}`:`to continue to ${((E=p==null?void 0:p.ui_settings)==null?void 0:E.app_name)||"App"}`;return e.jsxs(q1,{children:[e.jsxs(Y1,{children:[e.jsxs("div",{children:[e.jsx(Ae,{}),e.jsxs(ev,{children:[e.jsx(tv,{children:j}),e.jsx(rv,{children:S})]})]}),e.jsx($a,{showName:!0})]}),e.jsxs(Z1,{children:[e.jsxs(K1,{children:[e.jsxs(Q1,{children:[e.jsx(X1,{children:I?"Workspaces":"Your organizations"}),I&&e.jsxs(J1,{onClick:k,children:[e.jsx(Ur,{}),"Go back"]})]}),e.jsx(ov,{children:I?e.jsx(e.Fragment,{children:f&&f.length>0?f.map(T=>{var O,D,M;const P=((O=T.eligibility_restriction)==null?void 0:O.type)!=="none"&&((D=T.eligibility_restriction)==null?void 0:D.type)!==void 0;return e.jsxs($i,{onClick:()=>!P&&y(T),disabled:g===T.id||P,style:{opacity:P?.7:1},children:[e.jsx(zi,{children:T.image_url?e.jsx(Ei,{src:T.image_url,alt:T.name}):C(T.name).charAt(0)}),e.jsxs(Pi,{children:[e.jsx(Ri,{children:T.name}),e.jsxs(Ii,{children:[e.jsx(Lo,{}),"Workspace"]})]}),e.jsx(Ti,{children:e.jsx(ua,{})}),P&&e.jsxs(Oi,{children:[e.jsx(ut,{size:14}),(M=T.eligibility_restriction)==null?void 0:M.message]})]},T.id)}):e.jsxs(Mi,{children:[e.jsx(Li,{children:"No workspaces yet"}),e.jsxs(Ai,{children:["Create your first workspace for"," ",(b==null?void 0:b.name)||"this organization"]}),e.jsxs(Di,{onClick:()=>d("createWorkspace"),children:[e.jsx(Je,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(T=>{var re,X,U;const P=T.organization,O=n==null?void 0:n.filter(Z=>Z.organization.id===P.id),D=(O==null?void 0:O.length)||0,M=P.member_count,N=T.roles[0].name,F=T.roles.length-1,J=F>0?`${N.charAt(0).toUpperCase()+N.slice(1)} +${F}`:N.charAt(0).toUpperCase()+N.slice(1),ie=((re=T.eligibility_restriction)==null?void 0:re.type)!=="none"&&((X=T.eligibility_restriction)==null?void 0:X.type)!==void 0;return e.jsxs($i,{onClick:()=>!ie&&$(P),disabled:g===P.id||ie,style:{opacity:ie?.7:1},children:[e.jsx(zi,{children:P.image_url?e.jsx(Ei,{src:P.image_url,alt:P.name}):C(P.name)}),e.jsxs(Pi,{children:[e.jsx(Ri,{children:P.name}),e.jsx(Ii,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Lo,{}),D," workspace",D!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(rh,{}),J," • ",M," member",M!==1?"s":""]})})]}),e.jsx(Ti,{children:e.jsx(ua,{})}),ie&&e.jsxs(Oi,{children:[e.jsx(ut,{size:14}),(U=T.eligibility_restriction)==null?void 0:U.message]})]},P.id)}):e.jsxs(Mi,{children:[e.jsx(Li,{children:"No organizations yet"}),e.jsx(Ai,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(Di,{onClick:()=>d("createOrg"),children:[e.jsx(Je,{}),"Create organization"]})]})})]}),I&&f&&f.length>0&&e.jsxs(K,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createWorkspace"),disabled:g!==null,children:[e.jsx(Je,{size:12}),"Create new workspace"]}),!I&&t&&t.length>0&&v&&e.jsxs(K,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createOrg"),disabled:g!==null,children:[e.jsx(Je,{size:12}),"Create new organization"]})]})]})},av=u(we.Content)`
4805
4805
  padding: 0;
4806
4806
  max-width: 90vw;
4807
4807
  `,sv=({children:t})=>{var w,C,$,y;const{loading:r,session:o}=Fe(),{activeOrganization:n}=Qe(),{activeWorkspace:a,loading:s}=Pt(),{workspaces:p}=yt(),{deployment:g}=ve(),{organizationMemberships:c}=bt(),h=(g==null?void 0:g.b2b_settings.workspaces_enabled)??!1,d=c==null?void 0:c.find(z=>z.organization.id===(n==null?void 0:n.id)),l=p==null?void 0:p.find(z=>{var _;return z.id===((_=o==null?void 0:o.active_signin)==null?void 0:_.active_workspace_membership_id)}),m=((w=d==null?void 0:d.eligibility_restriction)==null?void 0:w.type)!=="none"&&((C=d==null?void 0:d.eligibility_restriction)==null?void 0:C.type)!==void 0,x=(($=l==null?void 0:l.eligibility_restriction)==null?void 0:$.type)!=="none"&&((y=l==null?void 0:l.eligibility_restriction)==null?void 0:y.type)!==void 0;return r||h&&s?null:(m||x||!n?!1:h?a?p==null?void 0:p.some(_=>_.id===a.id&&_.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(le,{children:e.jsx(we,{isOpen:!0,children:e.jsx(we.Overlay,{children:e.jsx(av,{style:{width:"850px"},children:e.jsx(nv,{})})})})})},iv=u.div`